home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / recode.lha / recode-3.2.4 / texinfo.tex (.txt) < prev    next >
LaTeX Document  |  1992-09-02  |  116KB  |  2,825 lines

  1. %% TeX macros to handle texinfo files
  2. %   Copyright (C) 1985, 86, 88, 90, 91, 92 Free Software Foundation, Inc.
  3. %This texinfo.tex file is free software; you can redistribute it and/or
  4. %modify it under the terms of the GNU General Public License as
  5. %published by the Free Software Foundation; either version 2, or (at
  6. %your option) any later version.
  7. %This texinfo.tex file is distributed in the hope that it will be
  8. %useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  9. %of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  10. %General Public License for more details.
  11. %You should have received a copy of the GNU General Public License
  12. %along with this texinfo.tex file; see the file COPYING.  If not, write
  13. %to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
  14. %USA.
  15. %In other words, you are welcome to use, share and improve this program.
  16. %You are forbidden to forbid anyone else to use, share and improve
  17. %what you give them.   Help stamp out software-hoarding!
  18. \def\texinfoversion{2.81}
  19. \message{Loading texinfo package [Version \texinfoversion]:}
  20. \message{}
  21. % Print the version number if in a .fmt file.
  22. \everyjob{\message{[Texinfo version \texinfoversion]}\message{}}
  23. % Save some parts of plain tex whose names we will redefine.
  24. \let\ptexlbrace=\{
  25. \let\ptexrbrace=\}
  26. \let\ptexdots=\dots
  27. \let\ptexdot=\.
  28. \let\ptexstar=\*
  29. \let\ptexend=\end
  30. \let\ptexbullet=\bullet
  31. \let\ptexb=\b
  32. \let\ptexc=\c
  33. \let\ptexi=\i
  34. \let\ptext=\t
  35. \let\ptexl=\l
  36. \let\ptexL=\L
  37. \def\tie{\penalty 10000\ }     % Save plain tex definition of ~.
  38. \message{Basics,}
  39. \chardef\other=12
  40. % If this character appears in an error message or help string, it
  41. % starts a new line in the output.
  42. \newlinechar = `^^J
  43. % Ignore a token.
  44. \def\gobble#1{}
  45. \hyphenation{ap-pen-dix}
  46. \hyphenation{mini-buf-fer mini-buf-fers}
  47. \hyphenation{eshell}
  48. % Margin to add to right of even pages, to left of odd pages.
  49. \newdimen \bindingoffset  \bindingoffset=0pt
  50. \newdimen \normaloffset   \normaloffset=\hoffset
  51. \newdimen\pagewidth \newdimen\pageheight
  52. \pagewidth=\hsize \pageheight=\vsize
  53. % Sometimes it is convenient to have everything in the transcript file
  54. % and nothing on the terminal.  We don't just call \tracingall here,
  55. % since that produces some useless output on the terminal.
  56. \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
  57. \def\loggingall{\tracingcommands2 \tracingstats2 
  58.    \tracingpages1 \tracingoutput1 \tracinglostchars1 
  59.    \tracingmacros2 \tracingparagraphs1 \tracingrestores1 
  60.    \showboxbreadth\maxdimen\showboxdepth\maxdimen
  61. %---------------------Begin change-----------------------
  62. %%%% For @cropmarks command.
  63. % Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986
  64. \newdimen\cornerlong \newdimen\cornerthick
  65. \newdimen \topandbottommargin
  66. \newdimen \outerhsize \newdimen \outervsize
  67. \cornerlong=1pc\cornerthick=.3pt    % These set size of cropmarks
  68. \outerhsize=7in
  69. %\outervsize=9.5in
  70. % Alternative @smallbook page size is 9.25in
  71. \outervsize=9.25in
  72. \topandbottommargin=.75in
  73. %---------------------End change-----------------------
  74. % \onepageout takes a vbox as an argument.  Note that \pagecontents
  75. % does insertions itself, but you have to call it yourself.
  76. \chardef\PAGE=255  \output={\onepageout{\pagecontents\PAGE}}
  77. \def\onepageout#1{\hoffset=\normaloffset
  78. \ifodd\pageno  \advance\hoffset by \bindingoffset
  79. \else \advance\hoffset by -\bindingoffset\fi
  80. {\escapechar=`\\\relax % makes sure backslash is used in output files.
  81. \shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}%
  82. {\let\hsize=\pagewidth \makefootline}}}%
  83. \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  84. %%%% For @cropmarks command %%%%
  85. % Here is a modification of the main output routine for Near East Publications
  86. % This provides right-angle cropmarks at all four corners.
  87. % The contents of the page are centerlined into the cropmarks,
  88. % and any desired binding offset is added as an \hskip on either
  89. % site of the centerlined box.  (P. A. MacKay, 12 November, 1986)
  90. \def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up
  91.          \shipout
  92.          \vbox to \outervsize{\hsize=\outerhsize
  93.                  \vbox{\line{\ewtop\hfill\ewtop}}
  94.                  \nointerlineskip
  95.                  \line{\vbox{\moveleft\cornerthick\nstop}
  96.                        \hfill
  97.                        \vbox{\moveright\cornerthick\nstop}}
  98.                  \vskip \topandbottommargin
  99.                  \centerline{\ifodd\pageno\hskip\bindingoffset\fi
  100.             \vbox{
  101.             {\let\hsize=\pagewidth \makeheadline}
  102.             \pagebody{#1}
  103.             {\let\hsize=\pagewidth \makefootline}}
  104.             \ifodd\pageno\else\hskip\bindingoffset\fi}
  105.          \vskip \topandbottommargin plus1fill minus1fill
  106.                  \boxmaxdepth\cornerthick
  107.                  \line{\vbox{\moveleft\cornerthick\nsbot}
  108.                        \hfill
  109.                        \vbox{\moveright\cornerthick\nsbot}}
  110.                  \nointerlineskip
  111.                  \vbox{\line{\ewbot\hfill\ewbot}}
  112.   \advancepageno 
  113.   \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  114. % Do @cropmarks to get crop marks
  115. \def\cropmarks{\let\onepageout=\croppageout }
  116. \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
  117. {\catcode`\@ =11
  118. \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
  119. \dimen@=\dp#1 \unvbox#1
  120. \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
  121. \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
  122. % Here are the rules for the cropmarks.  Note that they are
  123. % offset so that the space between them is truly \outerhsize or \outervsize
  124. % (P. A. MacKay, 12 November, 1986)
  125. \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
  126. \def\nstop{\vbox
  127.   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
  128. \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
  129. \def\nsbot{\vbox
  130.   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
  131. % Parse an argument, then pass it to #1.  The argument is the rest of
  132. % the input line (except we remove a trailing comment).  #1 should be a
  133. % macro which expects an ordinary undelimited TeX argument.
  134. \def\parsearg#1{%
  135.   \let\next = #1%
  136.   \begingroup
  137.     \obeylines
  138.     \futurelet\temp\parseargx
  139. % If the next token is an obeyed space (from an @example environment or
  140. % the like), remove it and recurse.  Otherwise, we're done.
  141. \def\parseargx{%
  142.   \ifx\obeyedspace\temp
  143.     \expandafter\parseargdiscardspace
  144.   \else
  145.     \expandafter\parseargline
  146.   \fi
  147. % Remove a single space (as the delimiter token to the macro call).
  148. {\obeyspaces %
  149.  \gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
  150. \gdef\obeyedspace{\ }
  151. {\obeylines %
  152.   \gdef\parseargline#1^^M{%
  153.     \endgroup % End of the group started in \parsearg.
  154.     %
  155.     % First remove any @c comment, then any @comment.
  156.     % Result of each macro is put in \toks0.
  157.     \argremovec #1\c\relax %
  158.     \expandafter\argremovecomment \the\toks0 \comment\relax %
  159.     %
  160.     % Call the caller's macro, saved as \next in \parsearg.
  161.     \expandafter\next\expandafter{\the\toks0}%
  162. % Since all \c{,omment} does is throw away the argument, we can let TeX
  163. % do that for us.  The \relax here is matched by the \relax in the call
  164. % in \parseargline; it could be more or less anything, its purpose is
  165. % just to delimit the argument to the \c.
  166. \def\argremovec#1\c#2\relax{\toks0 = {#1}}
  167. \def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
  168. % \argremovec{,omment} might leave us with trailing spaces, though; e.g.,
  169. %    @end itemize  @c foo
  170. % will have two active spaces as part of the argument with the
  171. % `itemize'.  Here we remove all active spaces from #1, and assign the
  172. % result to \toks0.
  173. % This loses if there are any *other* active characters besides spaces
  174. % in the argument -- _ ^ +, for example -- since they get expanded.
  175. % Fortunately, Texinfo does not define any such commands.  (If it ever
  176. % does, the catcode of the characters in questionwill have to be changed
  177. % here.)  But this means we cannot call \removeactivespaces as part of
  178. % \argremovec{,omment}, since @c uses \parsearg, and thus the argument
  179. % that \parsearg gets might well have any character at all in it.
  180. \def\removeactivespaces#1{%
  181.   \begingroup
  182.     \ignoreactivespaces
  183.     \edef\temp{#1}%
  184.     \global\toks0 = \expandafter{\temp}%
  185.   \endgroup
  186. % Change the active space to expand to nothing.
  187. \begingroup
  188.   \obeyspaces
  189.   \gdef\ignoreactivespaces{\obeyspaces\let =\empty}
  190. \endgroup
  191. \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
  192. %% These are used to keep @begin/@end levels from running away
  193. %% Call \inENV within environments (after a \begingroup)
  194. \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
  195. \def\ENVcheck{%
  196. \ifENV\errmessage{Still within an environment.  Type Return to continue.}
  197. \endgroup\fi} % This is not perfect, but it should reduce lossage
  198. % @begin foo  is the same as @foo, for now.
  199. \newhelp\EMsimple{Type <Return> to continue.}
  200. \outer\def\begin{\parsearg\beginxxx}
  201. \def\beginxxx #1{%
  202. \expandafter\ifx\csname #1\endcsname\relax
  203. {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
  204. \csname #1\endcsname\fi}
  205. % @end foo executes the definition of \Efoo.
  206. \def\end{\parsearg\endxxx}
  207. \def\endxxx #1{%
  208.   \removeactivespaces{#1}%
  209.   \edef\endthing{\the\toks0}%
  210.   \expandafter\ifx\csname E\endthing\endcsname\relax
  211.     \expandafter\ifx\csname \endthing\endcsname\relax
  212.       % There's no \foo, i.e., no ``environment'' foo.
  213.       \errhelp = \EMsimple
  214.       \errmessage{Undefined command `@end \endthing'}%
  215.     \else
  216.       % There is an environment foo, but it hasn't been started.
  217.       \errhelp = \EMsimple
  218.       \errmessage{This `@end \endthing' doesn't have a matching `@\endthing'}%
  219.     \fi
  220.   \else
  221.     % Everything's ok; the right environment has been started.
  222.     \csname E\endthing\endcsname
  223.   \fi
  224. % Single-spacing is done by various environments.
  225. \newskip\singlespaceskip \singlespaceskip = \baselineskip
  226. \def\singlespace{%
  227. {\advance \baselineskip by -\singlespaceskip
  228. \kern \baselineskip}%
  229. \baselineskip=\singlespaceskip
  230. %% Simple single-character @ commands
  231. % @@ prints an @
  232. % Kludge this until the fonts are right (grr).
  233. \def\@{{\tt \char '100}}
  234. % Define @` and @' to be the same as ` and '
  235. % but suppressing ligatures.
  236. \def\`{{`}}
  237. \def\'{{'}}
  238. % Used to generate quoted braces.
  239. \def\mylbrace {{\tt \char '173}}
  240. \def\myrbrace {{\tt \char '175}}
  241. \let\{=\mylbrace
  242. \let\}=\myrbrace
  243. % @: forces normal size whitespace following.
  244. \def\:{\spacefactor=1000 }
  245. % @* forces a line break.
  246. \def\*{\hfil\break\hbox{}\ignorespaces}
  247. % @. is an end-of-sentence period.
  248. \def\.{.\spacefactor=3000 }
  249. % @w prevents a word break.  Without the \leavevmode, @w at the
  250. % beginning of a paragraph, when TeX is still in vertical mode, would
  251. % produce a whole line of output instead of starting the paragraph.
  252. \def\w#1{\leavevmode\hbox{#1}}
  253. % @group ... @end group forces ... to be all on one page, by enclosing
  254. % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
  255. % to keep its height that of a normal line.  According to the rules for
  256. % \topskip (p.114 of the TeXbook), the glue inserted is
  257. % max (\topskip - \ht (first item), 0).  If that height is large,
  258. % therefore, no glue is inserted, and the space between the headline and
  259. % the text is small, which looks bad.
  260. \def\group{\begingroup
  261.   \ifnum\catcode13=\active \else
  262.     \errhelp = \groupinvalidhelp
  263.     \errmessage{@group invalid in context where filling is enabled}%
  264.   \fi
  265.   % If we don't do the \strut ... \nointerlineskip, we wind up with a
  266.   % box with a large depth, and hence get (typically) \lineskip leading
  267.   % (1pt), instead of the usual interline space (\baselineskip).  See
  268.   % p.82 of the TeXbook.
  269.   \def\Egroup{%
  270.     \strut            % Put in the normal leading.
  271.     \egroup           % End the \vtop.
  272.     \endgroup         % End the \group.
  273.     \nointerlineskip  % We inserted our own leading.
  274.   \vtop\bgroup
  275.     % We do @comment here in case we are called inside an environment,
  276.     % such as @example, where each end-of-line in the input causes an
  277.     % end-of-line in the output.  We don't want the end-of-line after
  278.     % the `@group' to put extra space in the output.  Since @group
  279.     % should appear on a line by itself (according to the Texinfo
  280.     % manual), we don't worry about eating any user text.
  281.     \comment
  282. % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
  283. % message, so this ends up printing `@group can only ...'.
  284. \newhelp\groupinvalidhelp{%
  285. group can only be used in environments such as @example,^^J%
  286. where each line of input produces a line of output.}
  287. % @need space-in-mils
  288. % forces a page break if there is not space-in-mils remaining.
  289. \newdimen\mil  \mil=0.001in
  290. \def\need{\parsearg\needx}
  291. % Old definition--didn't work.
  292. %\def\needx #1{\par %
  293. %% This method tries to make TeX break the page naturally
  294. %% if the depth of the box does not fit.
  295. %{\baselineskip=0pt%
  296. %\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000
  297. %\prevdepth=-1000pt
  298. \def\needx#1{%
  299.   % Go into vertical mode, so we don't make a big box in the middle of a
  300.   % paragraph.
  301.   \par
  302.   % Don't add any leading before our big empty box, but allow a page
  303.   % break, since the best break might be right here.
  304.   \allowbreak
  305.   \nointerlineskip
  306.   \vtop to #1\mil{\vfil}%
  307.   % TeX does not even consider page breaks if a penalty added to the
  308.   % main vertical list is 10000 or more.  But in order to see if the
  309.   % empty box we just added fits on the page, we must make it consider
  310.   % page breaks.  On the other hand, we don't want to actually break the
  311.   % page after the empty box.  So we use a penalty of 9999.
  312.   % There is an extremely small chance that TeX will actually break the
  313.   % page at this \penalty, if there are no other feasible breakpoints in
  314.   % sight.  (If the user is using lots of big @group commands, which
  315.   % almost-but-not-quite fill up a page, TeX will have a hard time doing
  316.   % good page breaking, for example.)  However, I could not construct an
  317.   % example where a page broke at this \penalty; if it happens in a real
  318.   % document, then we can reconsider our strategy.
  319.   \penalty9999
  320.   % Back up by the size of the box, whether we did a page break or not.
  321.   \kern -#1\mil
  322.   % Do not allow a page break right after this kern.
  323.   \nobreak
  324. % @br   forces paragraph break
  325. \let\br = \par
  326. % @dots{}  output some dots
  327. \def\dots{$\ldots$}
  328. % @page    forces the start of a new page
  329. \def\page{\par\vfill\supereject}
  330. % @exdent text....
  331. % outputs text on separate line in roman font, starting at standard page margin
  332. % This records the amount of indent in the innermost environment.
  333. % That's how much \exdent should take out.
  334. \newskip\exdentamount
  335. % This defn is used inside fill environments such as @defun.
  336. \def\exdent{\parsearg\exdentyyy}
  337. \def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}}
  338. % This defn is used inside nofill environments such as @example.
  339. \def\nofillexdent{\parsearg\nofillexdentyyy}
  340. \def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
  341. \leftline{\hskip\leftskip{\rm#1}}}}
  342. %\hbox{{\rm#1}}\hfil\break}}
  343. % @include file    insert text of that file as input.
  344. \def\include{\parsearg\includezzz}
  345. \def\includezzz #1{{\def\thisfile{#1}\input #1
  346. \def\thisfile{}
  347. % @center line   outputs that line, centered
  348. \def\center{\parsearg\centerzzz}
  349. \def\centerzzz #1{{\advance\hsize by -\leftskip
  350. \advance\hsize by -\rightskip
  351. \centerline{#1}}}
  352. % @sp n   outputs n lines of vertical space
  353. \def\sp{\parsearg\spxxx}
  354. \def\spxxx #1{\par \vskip #1\baselineskip}
  355. % @comment ...line which is ignored...
  356. % @c is the same as @comment
  357. % @ignore ... @end ignore  is another way to write a comment
  358. \def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other%
  359. \parsearg \commentxxx}
  360. \def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 }
  361. \let\c=\comment
  362. % Prevent errors for section commands.
  363. % Used in @ignore and in failing conditionals.
  364. \def\ignoresections{%
  365. \let\chapter=\relax
  366. \let\unnumbered=\relax
  367. \let\top=\relax
  368. \let\unnumberedsec=\relax
  369. \let\unnumberedsection=\relax
  370. \let\unnumberedsubsec=\relax
  371. \let\unnumberedsubsection=\relax
  372. \let\unnumberedsubsubsec=\relax
  373. \let\unnumberedsubsubsection=\relax
  374. \let\section=\relax
  375. \let\subsec=\relax
  376. \let\subsubsec=\relax
  377. \let\subsection=\relax
  378. \let\subsubsection=\relax
  379. \let\appendix=\relax
  380. \let\appendixsec=\relax
  381. \let\appendixsection=\relax
  382. \let\appendixsubsec=\relax
  383. \let\appendixsubsection=\relax
  384. \let\appendixsubsubsec=\relax
  385. \let\appendixsubsubsection=\relax
  386. \let\contents=\relax
  387. \let\smallbook=\relax
  388. \let\titlepage=\relax
  389. \def\ignore{\begingroup\ignoresections
  390. % Make sure that spaces turn into tokens that match what \ignorexxx wants.
  391. \catcode32=10
  392. \ignorexxx}
  393. \long\def\ignorexxx #1\end ignore{\endgroup\ignorespaces}
  394. \def\direntry{\begingroup\direntryxxx}
  395. \long\def\direntryxxx #1\end direntry{\endgroup\ignorespaces}
  396. % Conditionals to test whether a flag is set.
  397. \def\ifset{\begingroup\ignoresections\parsearg\ifsetxxx}
  398. \def\ifsetxxx #1{\endgroup
  399. \expandafter\ifx\csname SET#1\endcsname\relax \let\temp=\ifsetfail
  400. \else \let\temp=\relax \fi
  401. \temp}
  402. \def\Eifset{}
  403. \def\ifsetfail{\begingroup\ignoresections\ifsetfailxxx}
  404. \long\def\ifsetfailxxx #1\end ifset{\endgroup\ignorespaces}
  405. \def\ifclear{\begingroup\ignoresections\parsearg\ifclearxxx}
  406. \def\ifclearxxx #1{\endgroup
  407. \expandafter\ifx\csname SET#1\endcsname\relax \let\temp=\relax
  408. \else \let\temp=\ifclearfail \fi
  409. \temp}
  410. \def\Eifclear{}
  411. \def\ifclearfail{\begingroup\ignoresections\ifclearfailxxx}
  412. \long\def\ifclearfailxxx #1\end ifclear{\endgroup\ignorespaces}
  413. % @set foo
  414. %       to set the flag named foo to a default value (empty)
  415. % @set foo REST-OF-LINE
  416. %    to set the flag named foo to a text string REST-OF-LINE
  417. % @clear foo   to clear the flag named foo.
  418. % @value{foo} to set the text saved in foo
  419. % @set command, work macro \setyyy
  420. \def\setyyy#1 #2\endsetyyy{\expandafter\xdef\csname SET#1\endcsname{#2\unskip}}
  421. \def\setxxx#1{\setyyy#1 \endsetyyy}
  422. \def\set{\parsearg\setxxx}
  423. \def\clear{\parsearg\clearxxx}
  424. \def\clearxxx #1{
  425. \expandafter\let\csname SET#1\endcsname=\relax}
  426. \def\value#1{\expandafter
  427.         \ifx\csname SET#1\endcsname\relax
  428.             {\{No value for ``#1''\}}
  429.         \else \csname SET#1\endcsname \fi}
  430. % Some texinfo constructs that are trivial in tex
  431. \def\iftex{}
  432. \def\Eiftex{}
  433. \def\ifinfo{\begingroup\ignoresections\ifinfoxxx}
  434. \long\def\ifinfoxxx #1\end ifinfo{\endgroup\ignorespaces}
  435. \long\def\menu #1\end menu{}
  436. \def\asis#1{#1}
  437. % @math means output in math mode.
  438. % We don't use $'s directly in the definition of \math because control
  439. % sequences like \math are expanded when the toc file is written.  Then,
  440. % we read the toc file back, the $'s will be normal characters (as they
  441. % should be, according to the definition of Texinfo).  So we must use a
  442. % control sequence to switch into and out of math mode.
  443. % This isn't quite enough for @math to work properly in indices, but it
  444. % seems unlikely it will ever be needed there.
  445. \let\implicitmath = $
  446. \def\math#1{\implicitmath #1\implicitmath}
  447. \def\node{\ENVcheck\parsearg\nodezzz}
  448. \def\nodezzz#1{\nodexxx [#1,]}
  449. \def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
  450. \let\lastnode=\relax
  451. \def\donoderef{\ifx\lastnode\relax\else
  452. \expandafter\expandafter\expandafter\setref{\lastnode}\fi
  453. \let\lastnode=\relax}
  454. \def\unnumbnoderef{\ifx\lastnode\relax\else
  455. \expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi
  456. \let\lastnode=\relax}
  457. \def\appendixnoderef{\ifx\lastnode\relax\else
  458. \expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi
  459. \let\lastnode=\relax}
  460. \let\refill=\relax
  461. % @setfilename is done at the beginning of every texinfo file.
  462. % So open here the files we need to have open while reading the input.
  463. % This makes it possible to make a .fmt file for texinfo.
  464. \def\setfilename{%
  465.    \readauxfile
  466.    \opencontents
  467.    \openindices
  468.    \fixbackslash  % Turn off hack to swallow `\input texinfo'.
  469.    \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
  470.    \comment % Ignore the actual filename.
  471. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
  472. \def\inforef #1{\inforefzzz #1,,,,**}
  473. \def\inforefzzz #1,#2,#3,#4**{See Info file \file{\losespace#3{}},
  474.   node \samp{\losespace#1{}}}
  475. \def\losespace #1{#1}
  476. \message{fonts,}
  477. % Font-change commands.
  478. % Texinfo supports the sans serif font style, which plain TeX does not.
  479. % So we set up a \sf analogous to plain's \rm, etc.
  480. \newfam\sffam
  481. \def\sf{\fam=\sffam \tensf}
  482. \let\li = \sf % Sometimes we call it \li, not \sf.
  483. %% Try out Computer Modern fonts at \magstephalf
  484. \let\mainmagstep=\magstephalf
  485. \ifx\bigger\relax
  486. \let\mainmagstep=\magstep1
  487. \font\textrm=cmr12
  488. \font\texttt=cmtt12
  489. \else
  490. \font\textrm=cmr10 scaled \mainmagstep
  491. \font\texttt=cmtt10 scaled \mainmagstep
  492. % Instead of cmb10, you many want to use cmbx10.
  493. % cmbx10 is a prettier font on its own, but cmb10
  494. % looks better when embedded in a line with cmr10.
  495. \font\textbf=cmb10 scaled \mainmagstep 
  496. \font\textit=cmti10 scaled \mainmagstep
  497. \font\textsl=cmsl10 scaled \mainmagstep
  498. \font\textsf=cmss10 scaled \mainmagstep
  499. \font\textsc=cmcsc10 scaled \mainmagstep
  500. \font\texti=cmmi10 scaled \mainmagstep
  501. \font\textsy=cmsy10 scaled \mainmagstep
  502. % A few fonts for @defun, etc.
  503. \font\defbf=cmbx10 scaled \magstep1 %was 1314
  504. \font\deftt=cmtt10 scaled \magstep1
  505. \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf}
  506. % Fonts for indices and small examples.
  507. % We actually use the slanted font rather than the italic, 
  508. % because texinfo normally uses the slanted fonts for that.
  509. % Do not make many font distinctions in general in the index, since they
  510. % aren't very useful.
  511. \font\ninett=cmtt9
  512. \font\indrm=cmr9
  513. \font\indit=cmsl9
  514. \let\indsl=\indit
  515. \let\indtt=\ninett
  516. \let\indsf=\indrm
  517. \let\indbf=\indrm
  518. \let\indsc=\indrm
  519. \font\indi=cmmi9
  520. \font\indsy=cmsy9
  521. % Fonts for headings
  522. \font\chaprm=cmbx12 scaled \magstep2
  523. \font\chapit=cmti12 scaled \magstep2
  524. \font\chapsl=cmsl12 scaled \magstep2
  525. \font\chaptt=cmtt12 scaled \magstep2
  526. \font\chapsf=cmss12 scaled \magstep2
  527. \let\chapbf=\chaprm
  528. \font\chapsc=cmcsc10 scaled\magstep3
  529. \font\chapi=cmmi12 scaled \magstep2
  530. \font\chapsy=cmsy10 scaled \magstep3
  531. \font\secrm=cmbx12 scaled \magstep1
  532. \font\secit=cmti12 scaled \magstep1
  533. \font\secsl=cmsl12 scaled \magstep1
  534. \font\sectt=cmtt12 scaled \magstep1
  535. \font\secsf=cmss12 scaled \magstep1
  536. \font\secbf=cmbx12 scaled \magstep1
  537. \font\secsc=cmcsc10 scaled\magstep2
  538. \font\seci=cmmi12 scaled \magstep1
  539. \font\secsy=cmsy10 scaled \magstep2
  540. % \font\ssecrm=cmbx10 scaled \magstep1    % This size an font looked bad.
  541. % \font\ssecit=cmti10 scaled \magstep1    % The letters were too crowded.
  542. % \font\ssecsl=cmsl10 scaled \magstep1
  543. % \font\ssectt=cmtt10 scaled \magstep1
  544. % \font\ssecsf=cmss10 scaled \magstep1
  545. %\font\ssecrm=cmb10 scaled 1315    % Note the use of cmb rather than cmbx.
  546. %\font\ssecit=cmti10 scaled 1315    % Also, the size is a little larger than
  547. %\font\ssecsl=cmsl10 scaled 1315    % being scaled magstep1.
  548. %\font\ssectt=cmtt10 scaled 1315
  549. %\font\ssecsf=cmss10 scaled 1315
  550. %\let\ssecbf=\ssecrm
  551. \font\ssecrm=cmbx12 scaled \magstephalf
  552. \font\ssecit=cmti12 scaled \magstephalf
  553. \font\ssecsl=cmsl12 scaled \magstephalf
  554. \font\ssectt=cmtt12 scaled \magstephalf
  555. \font\ssecsf=cmss12 scaled \magstephalf
  556. \font\ssecbf=cmbx12 scaled \magstephalf
  557. \font\ssecsc=cmcsc10 scaled \magstep1 
  558. \font\sseci=cmmi12 scaled \magstephalf
  559. \font\ssecsy=cmsy10 scaled \magstep1
  560. % The smallcaps and symbol fonts should actually be scaled \magstep1.5,
  561. % but that is not a standard magnification.
  562. % Fonts for title page:
  563. \font\titlerm = cmbx12 scaled \magstep3
  564. \let\authorrm = \secrm
  565. % In order for the font changes to affect most math symbols and letters,
  566. % we have to define the \textfont of the standard families.  Since
  567. % texinfo doesn't allow for producing subscripts and superscripts, we
  568. % don't bother to reset \scriptfont and \scriptscriptfont (which would
  569. % also require loading a lot more fonts).
  570. \def\resetmathfonts{%
  571.   \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy
  572.   \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf
  573.   \textfont\ttfam = \tentt \textfont\sffam = \tensf
  574. % The font-changing commands redefine the meanings of \tenSTYLE, instead
  575. % of just \STYLE.  We do this so that font changes will continue to work
  576. % in math mode, where it is the current \fam that is relevant in most
  577. % cases, not the current.  Plain TeX does, for example,
  578. % \def\bf{\fam=\bffam \tenbf}  By redefining \tenbf, we obviate the need
  579. % to redefine \bf itself.  
  580. \def\textfonts{%
  581.   \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
  582.   \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
  583.   \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
  584.   \resetmathfonts}
  585. \def\chapfonts{%
  586.   \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl 
  587.   \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
  588.   \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
  589.   \resetmathfonts}
  590. \def\secfonts{%
  591.   \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
  592.   \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
  593.   \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
  594.   \resetmathfonts}
  595. \def\subsecfonts{%
  596.   \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
  597.   \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
  598.   \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
  599.   \resetmathfonts}
  600. \def\indexfonts{%
  601.   \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl
  602.   \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc
  603.   \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy
  604.   \resetmathfonts}
  605. % Set up the default fonts, so we can use them for creating boxes.
  606. \textfonts
  607. % Count depth in font-changes, for error checks
  608. \newcount\fontdepth \fontdepth=0
  609. % Fonts for short table of contents.
  610. \font\shortcontrm=cmr12
  611. \font\shortcontbf=cmbx12
  612. \font\shortcontsl=cmsl12
  613. %% Add scribe-like font environments, plus @l for inline lisp (usually sans
  614. %% serif) and @ii for TeX italic
  615. % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
  616. % unless the following character is such as not to need one.
  617. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
  618. \def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx}
  619. \let\i=\smartitalic
  620. \let\var=\smartitalic
  621. \let\dfn=\smartitalic
  622. \let\emph=\smartitalic
  623. \let\cite=\smartitalic
  624. \def\b#1{{\bf #1}}
  625. \let\strong=\b
  626. \def\t#1{{\tt \exhyphenpenalty=10000\rawbackslash \frenchspacing #1}\null}
  627. \let\ttfont = \t
  628. %\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null}
  629. \def\samp #1{`\tclose{#1}'\null}
  630. \def\key #1{{\tt \exhyphenpenalty=10000\uppercase{#1}}\null}
  631. \def\ctrl #1{{\tt \rawbackslash \hat}#1}
  632. \let\file=\samp
  633. % @code is a modification of @t,
  634. % which makes spaces the same size as normal in the surrounding text.
  635. \newdimen\tclosesave
  636. \newdimen\tcloserm
  637. \def\tclose#1{{\rm \tcloserm=\fontdimen2\font \tt \tclosesave=\fontdimen2\font
  638. \fontdimen2\font=\tcloserm
  639. % prevent breaking lines at hyphens.
  640. \exhyphenpenalty=10000
  641. \def\ {{\fontdimen2\font=\tclosesave{} }}%
  642.  \rawbackslash \frenchspacing #1\fontdimen2\font=\tclosesave}\null}
  643. \let\code=\tclose
  644. %\let\exp=\tclose  %Was temporary
  645. % @kbd is like @code, except that if the argument is just one @key command, 
  646. % then @kbd has no effect.
  647. \def\xkey{\key}
  648. \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
  649. \ifx\one\xkey\ifx\threex\three \key{#2}%
  650. \else\tclose{\look}\fi
  651. \else\tclose{\look}\fi}
  652. % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
  653. % argument is to make the input look right: @dmn{pt} instead of
  654. % @dmn{}pt.
  655. \def\dmn#1{\thinspace #1}
  656. \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
  657. \def\l#1{{\li #1}\null}        % 
  658. \def\r#1{{\rm #1}}        % roman font
  659. % Use of \lowercase was suggested.
  660. \def\sc#1{{\smallcaps#1}}    % smallcaps font
  661. \def\ii#1{{\it #1}}        % italic font
  662. \message{page headings,}
  663. \newskip\titlepagetopglue \titlepagetopglue = 1.5in
  664. \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
  665. % First the title page.  Must do @settitle before @titlepage.
  666. \def\titlefont#1{{\titlerm #1}}
  667. \newtoks\realeverypar
  668. \newif\ifseenauthor
  669. \newif\iffinishedtitlepage
  670. \def\titlepage{\begingroup \parindent=0pt \textfonts
  671.    \let\subtitlerm=\tenrm
  672. % I deinstalled the following change because \cmr12 is undefined.
  673. % This change was not in the ChangeLog anyway.  --rms.
  674. %   \let\subtitlerm=\cmr12
  675.    \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
  676.    \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
  677.    % Leave some space at the very top of the page.
  678.    \vglue\titlepagetopglue
  679.    % Now you can print the title using @title.
  680.    \def\title{\parsearg\titlezzz}%
  681.    \def\titlezzz##1{\leftline{\titlefont{##1}}
  682.             % print a rule at the page bottom also.
  683.             \finishedtitlepagefalse
  684.             \vskip4pt \hrule height 4pt \vskip4pt}%
  685.    % No rule at page bottom unless we print one at the top with @title.
  686.    \finishedtitlepagetrue
  687.    % Now you can put text using @subtitle.
  688.    \def\subtitle{\parsearg\subtitlezzz}%
  689.    \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
  690.    % @author should come last, but may come many times.
  691.    \def\author{\parsearg\authorzzz}%
  692.    \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
  693.       {\authorfont \leftline{##1}}}%
  694.    %  
  695.    % Most title ``pages'' are actually two pages long, with space
  696.    % at the top of the second.  We don't want the ragged left on the second.
  697.    \let\oldpage = \page
  698.    \def\page{%
  699.       \iffinishedtitlepage\else
  700.      \finishtitlepage
  701.       \fi
  702.       \oldpage
  703.       \let\page = \oldpage
  704.       \hbox{}}%
  705. %   \def\page{\oldpage \hbox{}}
  706. \def\Etitlepage{%
  707.    \iffinishedtitlepage\else
  708.       \finishtitlepage
  709.    \fi
  710.    % It is important to do the page break before ending the group,
  711.    % because the headline and footline are only empty inside the group.
  712.    % If we use the new definition of \page, we always get a blank page
  713.    % after the title page, which we certainly don't want.
  714.    \oldpage
  715.    \endgroup
  716.    \HEADINGSon
  717. \def\finishtitlepage{%
  718.    \vskip4pt \hrule height 2pt
  719.    \vskip\titlepagebottomglue
  720.    \finishedtitlepagetrue
  721. %%% Set up page headings and footings.
  722. \let\thispage=\folio
  723. \newtoks \evenheadline    % Token sequence for heading line of even pages
  724. \newtoks \oddheadline     % Token sequence for heading line of odd pages
  725. \newtoks \evenfootline    % Token sequence for footing line of even pages
  726. \newtoks \oddfootline     % Token sequence for footing line of odd pages
  727. % Now make Tex use those variables
  728. \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
  729.                             \else \the\evenheadline \fi}}
  730. \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
  731.                             \else \the\evenfootline \fi}\HEADINGShook}
  732. \let\HEADINGShook=\relax
  733. % Commands to set those variables.
  734. % For example, this is what  @headings on  does
  735. % @evenheading @thistitle|@thispage|@thischapter
  736. % @oddheading @thischapter|@thispage|@thistitle
  737. % @evenfooting @thisfile||
  738. % @oddfooting ||@thisfile
  739. \def\evenheading{\parsearg\evenheadingxxx}
  740. \def\oddheading{\parsearg\oddheadingxxx}
  741. \def\everyheading{\parsearg\everyheadingxxx}
  742. \def\evenfooting{\parsearg\evenfootingxxx}
  743. \def\oddfooting{\parsearg\oddfootingxxx}
  744. \def\everyfooting{\parsearg\everyfootingxxx}
  745. {\catcode`\@=0 %
  746. \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
  747. \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
  748. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  749. \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
  750. \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
  751. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  752. \gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish}
  753. \gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{%
  754. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  755. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  756. \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
  757. \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
  758. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  759. \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
  760. \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
  761. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  762. \gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish}
  763. \gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{%
  764. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  765. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  766. }% unbind the catcode of @.
  767. % @headings double    turns headings on for double-sided printing.
  768. % @headings single    turns headings on for single-sided printing.
  769. % @headings off        turns them off.
  770. % @headings on        same as @headings double, retained for compatibility.
  771. % @headings after    turns on double-sided headings after this page.
  772. % @headings doubleafter    turns on double-sided headings after this page.
  773. % @headings singleafter turns on single-sided headings after this page.
  774. % By default, they are off.
  775. \def\headings #1 {\csname HEADINGS#1\endcsname}
  776. \def\HEADINGSoff{
  777. \global\evenheadline={\hfil} \global\evenfootline={\hfil}
  778. \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
  779. \HEADINGSoff
  780. % When we turn headings on, set the page number to 1.
  781. % For double-sided printing, put current file name in lower left corner,
  782. % chapter name on inside top of right hand pages, document
  783. % title on inside top of left hand pages, and page numbers on outside top
  784. % edge of all pages.
  785. \def\HEADINGSdouble{
  786. %\pagealignmacro
  787. \global\pageno=1
  788. \global\evenfootline={\hfil}
  789. \global\oddfootline={\hfil}
  790. \global\evenheadline={\line{\folio\hfil\thistitle}}
  791. \global\oddheadline={\line{\thischapter\hfil\folio}}
  792. % For single-sided printing, chapter title goes across top left of page,
  793. % page number on top right.
  794. \def\HEADINGSsingle{
  795. %\pagealignmacro
  796. \global\pageno=1
  797. \global\evenfootline={\hfil}
  798. \global\oddfootline={\hfil}
  799. \global\evenheadline={\line{\thischapter\hfil\folio}}
  800. \global\oddheadline={\line{\thischapter\hfil\folio}}
  801. \def\HEADINGSon{\HEADINGSdouble}
  802. \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
  803. \let\HEADINGSdoubleafter=\HEADINGSafter
  804. \def\HEADINGSdoublex{%
  805. \global\evenfootline={\hfil}
  806. \global\oddfootline={\hfil}
  807. \global\evenheadline={\line{\folio\hfil\thistitle}}
  808. \global\oddheadline={\line{\thischapter\hfil\folio}}
  809. \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
  810. \def\HEADINGSsinglex{%
  811. \global\evenfootline={\hfil}
  812. \global\oddfootline={\hfil}
  813. \global\evenheadline={\line{\thischapter\hfil\folio}}
  814. \global\oddheadline={\line{\thischapter\hfil\folio}}
  815. % Subroutines used in generating headings
  816. % Produces Day Month Year style of output.
  817. \def\today{\number\day\space
  818. \ifcase\month\or
  819. January\or February\or March\or April\or May\or June\or
  820. July\or August\or September\or October\or November\or December\fi
  821. \space\number\year}
  822. % Use this if you want the Month Day, Year style of output.
  823. %\def\today{\ifcase\month\or
  824. %January\or February\or March\or April\or May\or June\or
  825. %July\or August\or September\or October\or November\or December\fi
  826. %\space\number\day, \number\year}
  827. % @settitle line...  specifies the title of the document, for headings
  828. % It generates no output of its own
  829. \def\thistitle{No Title}
  830. \def\settitle{\parsearg\settitlezzz}
  831. \def\settitlezzz #1{\gdef\thistitle{#1}}
  832. \message{tables,}
  833. % @tabs -- simple alignment
  834. % These don't work.  For one thing, \+ is defined as outer.
  835. % So these macros cannot even be defined.
  836. %\def\tabs{\parsearg\tabszzz}
  837. %\def\tabszzz #1{\settabs\+#1\cr}
  838. %\def\tabline{\parsearg\tablinezzz}
  839. %\def\tablinezzz #1{\+#1\cr}
  840. %\def\&{&}
  841. % Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x).
  842. % default indentation of table text
  843. \newdimen\tableindent \tableindent=.8in
  844. % default indentation of @itemize and @enumerate text
  845. \newdimen\itemindent  \itemindent=.3in
  846. % margin between end of table item and start of table text.
  847. \newdimen\itemmargin  \itemmargin=.1in
  848. % used internally for \itemindent minus \itemmargin
  849. \newdimen\itemmax
  850. % Note @table, @vtable, and @vtable define @item, @itemx, etc., with
  851. % these defs.
  852. % They also define \itemindex
  853. % to index the item name in whatever manner is desired (perhaps none).
  854. \def\internalBitem{\smallbreak \parsearg\itemzzz}
  855. \def\internalBitemx{\par \parsearg\itemzzz}
  856. \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
  857. \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \par \parsearg\xitemzzz}
  858. \def\internalBkitem{\smallbreak \parsearg\kitemzzz}
  859. \def\internalBkitemx{\par \parsearg\kitemzzz}
  860. \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}%
  861.                  \itemzzz {#1}}
  862. \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}%
  863.                  \itemzzz {#1}}
  864. \def\itemzzz #1{\begingroup %
  865.   \advance\hsize by -\rightskip
  866.   \advance\hsize by -\tableindent
  867.   \setbox0=\hbox{\itemfont{#1}}%
  868.   \itemindex{#1}%
  869.   \nobreak % This prevents a break before @itemx.
  870.   % Be sure we are not still in the middle of a paragraph.
  871.   \parskip=0in
  872.   \par
  873.   % If the item text does not fit in the space we have, put it on a line
  874.   % by itself, and do not allow a page break either before or after that
  875.   % line.  We do not start a paragraph here because then if the next
  876.   % command is, e.g., @kindex, the whatsit would get put into the
  877.   % horizontal list on a line by itself, resulting in extra blank space.
  878.   \ifdim \wd0>\itemmax
  879.     \setbox0=\hbox{\hskip \leftskip \hskip -\tableindent \unhbox0}\box0
  880.     \nobreak
  881.   \else
  882.     % The item text fits into the space.  Start a paragraph, so that the
  883.     % following text (if any) will end up on the same line.  Since that
  884.     % text will be indented by \tableindent, we make the item text be in
  885.     % a zero-width box.
  886.     \noindent
  887.     \rlap{\hskip -\tableindent\box0}%
  888.   \fi
  889.   \endgroup
  890. \def\item{\errmessage{@item while not in a table}}
  891. \def\itemx{\errmessage{@itemx while not in a table}}
  892. \def\kitem{\errmessage{@kitem while not in a table}}
  893. \def\kitemx{\errmessage{@kitemx while not in a table}}
  894. \def\xitem{\errmessage{@xitem while not in a table}}
  895. \def\xitemx{\errmessage{@xitemx while not in a table}}
  896. %% Contains a kludge to get @end[description] to work
  897. \def\description{\tablez{\dontindex}{1}{}{}{}{}}
  898. \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
  899. {\obeylines\obeyspaces%
  900. \gdef\tablex #1^^M{%
  901. \tabley\dontindex#1        \endtabley}}
  902. \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
  903. {\obeylines\obeyspaces%
  904. \gdef\ftablex #1^^M{%
  905. \tabley\fnitemindex#1        \endtabley
  906. \def\Eftable{\endgraf\endgroup\afterenvbreak}%
  907. \let\Etable=\relax}}
  908. \def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex}
  909. {\obeylines\obeyspaces%
  910. \gdef\vtablex #1^^M{%
  911. \tabley\vritemindex#1        \endtabley
  912. \def\Evtable{\endgraf\endgroup\afterenvbreak}%
  913. \let\Etable=\relax}}
  914. \def\dontindex #1{}
  915. \def\fnitemindex #1{\doind {fn}{\code{#1}}}%
  916. \def\vritemindex #1{\doind {vr}{\code{#1}}}%
  917. {\obeyspaces %
  918. \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
  919. \tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
  920. \def\tablez #1#2#3#4#5#6{%
  921. \aboveenvbreak %
  922. \begingroup %
  923. \def\Edescription{\Etable}% Neccessary kludge.
  924. \let\itemindex=#1%
  925. \ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
  926. \ifnum 0#4>0 \tableindent=#4\mil \fi %
  927. \ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
  928. \def\itemfont{#2}%
  929. \itemmax=\tableindent %
  930. \advance \itemmax by -\itemmargin %
  931. \advance \leftskip by \tableindent %
  932. \exdentamount=\tableindent
  933. \parindent = 0pt
  934. \parskip = \smallskipamount
  935. \ifdim \parskip=0pt \parskip=2pt \fi%
  936. \def\Etable{\endgraf\endgroup\afterenvbreak}%
  937. \let\item = \internalBitem %
  938. \let\itemx = \internalBitemx %
  939. \let\kitem = \internalBkitem %
  940. \let\kitemx = \internalBkitemx %
  941. \let\xitem = \internalBxitem %
  942. \let\xitemx = \internalBxitemx %
  943. % This is the counter used by @enumerate, which is really @itemize
  944. \newcount \itemno
  945. \def\itemize{\parsearg\itemizezzz}
  946. \def\itemizezzz #1{%
  947.   \begingroup % ended by the @end itemsize
  948.   \itemizey {#1}{\Eitemize}
  949. \def\itemizey #1#2{%
  950. \aboveenvbreak %
  951. \itemmax=\itemindent %
  952. \advance \itemmax by -\itemmargin %
  953. \advance \leftskip by \itemindent %
  954. \exdentamount=\itemindent
  955. \parindent = 0pt %
  956. \parskip = \smallskipamount %
  957. \ifdim \parskip=0pt \parskip=2pt \fi%
  958. \def#2{\endgraf\endgroup\afterenvbreak}%
  959. \def\itemcontents{#1}%
  960. \let\item=\itemizeitem}
  961. \def\bullet{$\ptexbullet$}
  962. \def\minus{$-$}
  963. % Set sfcode to normal for the chars that usually have another value.
  964. % These are `.?!:;,'
  965. \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
  966.   \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
  967. % \splitoff TOKENS\endmark defines \first to be the first token in
  968. % TOKENS, and \rest to be the remainder.
  969. \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
  970. % Allow an optional argument of an uppercase letter, lowercase letter,
  971. % or number, to specify the first label in the enumerated list.  No
  972. % argument is the same as `1'.
  973. \def\enumerate{\parsearg\enumeratezzz}
  974. \def\enumeratezzz #1{\enumeratey #1  \endenumeratey}
  975. \def\enumeratey #1 #2\endenumeratey{%
  976.   \begingroup % ended by the @end enumerate
  977.   % If we were given no argument, pretend we were given `1'.
  978.   \def\thearg{#1}%
  979.   \ifx\thearg\empty \def\thearg{1}\fi
  980.   % Detect if the argument is a single token.  If so, it might be a
  981.   % letter.  Otherwise, the only valid thing it can be is a number.
  982.   % (We will always have one token, because of the test we just made.
  983.   % This is a good thing, since \splitoff doesn't work given nothing at
  984.   % all -- the first parameter is undelimited.)
  985.   \expandafter\splitoff\thearg\endmark
  986.   \ifx\rest\empty
  987.     % Only one token in the argument.  It could still be anything.
  988.     % A ``lowercase letter'' is one whose \lccode is nonzero.
  989.     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
  990.     %   not equal to itself.
  991.     % Otherwise, we assume it's a number.
  992.     % 
  993.     % We need the \relax at the end of the \ifnum lines to stop TeX from
  994.     % continuing to look for a <number>.
  995.     % 
  996.     \ifnum\lccode\expandafter`\thearg=0\relax 
  997.       \numericenumerate % a number (we hope)
  998.     \else
  999.       % It's a letter.
  1000.       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
  1001.         \lowercaseenumerate % lowercase letter
  1002.       \else
  1003.         \uppercaseenumerate % uppercase letter
  1004.       \fi
  1005.     \fi
  1006.   \else
  1007.     % Multiple tokens in the argument.  We hope it's a number.
  1008.     \numericenumerate
  1009.   \fi
  1010. % An @enumerate whose labels are integers.  The starting integer is
  1011. % given in \thearg.
  1012. \def\numericenumerate{%
  1013.   \itemno = \thearg
  1014.   \startenumeration{\the\itemno}%
  1015. % The starting (lowercase) letter is in \thearg.
  1016. \def\lowercaseenumerate{%
  1017.   \itemno = \expandafter`\thearg
  1018.   \startenumeration{%
  1019.     % Be sure we're not beyond the end of the alphabet.
  1020.     \ifnum\itemno=0
  1021.       \errmessage{No more lowercase letters in @enumerate; get a bigger
  1022.                   alphabet}%
  1023.     \fi
  1024.     \char\lccode\itemno
  1025. % The starting (uppercase) letter is in \thearg.
  1026. \def\uppercaseenumerate{%
  1027.   \itemno = \expandafter`\thearg
  1028.   \startenumeration{%
  1029.     % Be sure we're not beyond the end of the alphabet.
  1030.     \ifnum\itemno=0
  1031.       \errmessage{No more uppercase letters in @enumerate; get a bigger
  1032.                   alphabet}
  1033.     \fi
  1034.     \char\uccode\itemno
  1035. % Call itemizey, adding a period to the first argument and supplying the
  1036. % common last two arguments.  Also subtract one from the initial value in
  1037. % \itemno, since @item increments \itemno.
  1038. \def\startenumeration#1{%
  1039.   \advance\itemno by -1
  1040.   \itemizey{#1.}\Eenumerate\flushcr
  1041. % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
  1042. % to @enumerate.
  1043. \def\alphaenumerate{\enumerate{a}}
  1044. \def\capsenumerate{\enumerate{A}}
  1045. \def\Ealphaenumerate{\Eenumerate}
  1046. \def\Ecapsenumerate{\Eenumerate}
  1047. % Definition of @item while inside @itemize.
  1048. \def\itemizeitem{%
  1049. \advance\itemno by 1
  1050. {\let\par=\endgraf \smallbreak}%
  1051. \ifhmode \errmessage{\in hmode at itemizeitem}\fi
  1052. {\parskip=0in \hskip 0pt
  1053. \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
  1054. \vadjust{\penalty 1200}}%
  1055. \flushcr}
  1056. \message{indexing,}
  1057. % Index generation facilities
  1058. % Define \newwrite to be identical to plain tex's \newwrite
  1059. % except not \outer, so it can be used within \newindex.
  1060. {\catcode`\@=11
  1061. \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
  1062. % \newindex {foo} defines an index named foo.
  1063. % It automatically defines \fooindex such that
  1064. % \fooindex ...rest of line... puts an entry in the index foo.
  1065. % It also defines \fooindfile to be the number of the output channel for
  1066. % the file that    accumulates this index.  The file's extension is foo.
  1067. % The name of an index should be no more than 2 characters long
  1068. % for the sake of vms.
  1069. \def\newindex #1{
  1070. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  1071. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  1072. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1073. \noexpand\doindex {#1}}
  1074. % @defindex foo  ==  \newindex{foo}
  1075. \def\defindex{\parsearg\newindex}
  1076. % Define @defcodeindex, like @defindex except put all entries in @code.
  1077. \def\newcodeindex #1{
  1078. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  1079. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  1080. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1081. \noexpand\docodeindex {#1}}
  1082. \def\defcodeindex{\parsearg\newcodeindex}
  1083. % @synindex foo bar    makes index foo feed into index bar.
  1084. % Do this instead of @defindex foo if you don't want it as a separate index.
  1085. \def\synindex #1 #2 {%
  1086. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  1087. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  1088. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1089. \noexpand\doindex {#2}}%
  1090. % @syncodeindex foo bar   similar, but put all entries made for index foo
  1091. % inside @code.
  1092. \def\syncodeindex #1 #2 {%
  1093. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  1094. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  1095. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1096. \noexpand\docodeindex {#2}}%
  1097. % Define \doindex, the driver for all \fooindex macros.
  1098. % Argument #1 is generated by the calling \fooindex macro,
  1099. %  and it is "foo", the name of the index.
  1100. % \doindex just uses \parsearg; it calls \doind for the actual work.
  1101. % This is because \doind is more useful to call from other macros.
  1102. % There is also \dosubind {index}{topic}{subtopic}
  1103. % which makes an entry in a two-level index such as the operation index.
  1104. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
  1105. \def\singleindexer #1{\doind{\indexname}{#1}}
  1106. % like the previous two, but they put @code around the argument.
  1107. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
  1108. \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
  1109. \def\indexdummies{%
  1110. \def\_{{\realbackslash _}}%
  1111. \def\w{\realbackslash w }%
  1112. \def\bf{\realbackslash bf }%
  1113. \def\rm{\realbackslash rm }%
  1114. \def\sl{\realbackslash sl }%
  1115. \def\sf{\realbackslash sf}%
  1116. \def\tt{\realbackslash tt}%
  1117. \def\gtr{\realbackslash gtr}%
  1118. \def\less{\realbackslash less}%
  1119. \def\hat{\realbackslash hat}%
  1120. \def\char{\realbackslash char}%
  1121. \def\TeX{\realbackslash TeX}%
  1122. \def\dots{\realbackslash dots }%
  1123. \def\copyright{\realbackslash copyright }%
  1124. \def\tclose##1{\realbackslash tclose {##1}}%
  1125. \def\code##1{\realbackslash code {##1}}%
  1126. \def\samp##1{\realbackslash samp {##1}}%
  1127. \def\t##1{\realbackslash r {##1}}%
  1128. \def\r##1{\realbackslash r {##1}}%
  1129. \def\i##1{\realbackslash i {##1}}%
  1130. \def\b##1{\realbackslash b {##1}}%
  1131. \def\cite##1{\realbackslash cite {##1}}%
  1132. \def\key##1{\realbackslash key {##1}}%
  1133. \def\file##1{\realbackslash file {##1}}%
  1134. \def\var##1{\realbackslash var {##1}}%
  1135. \def\kbd##1{\realbackslash kbd {##1}}%
  1136. % \indexnofonts no-ops all font-change commands.
  1137. % This is used when outputting the strings to sort the index by.
  1138. \def\indexdummyfont#1{#1}
  1139. \def\indexdummytex{TeX}
  1140. \def\indexdummydots{...}
  1141. \def\indexnofonts{%
  1142. \let\w=\indexdummyfont
  1143. \let\t=\indexdummyfont
  1144. \let\r=\indexdummyfont
  1145. \let\i=\indexdummyfont
  1146. \let\b=\indexdummyfont
  1147. \let\emph=\indexdummyfont
  1148. \let\strong=\indexdummyfont
  1149. \let\cite=\indexdummyfont
  1150. \let\sc=\indexdummyfont
  1151. %Don't no-op \tt, since it isn't a user-level command
  1152. % and is used in the definitions of the active chars like <, >, |...
  1153. %\let\tt=\indexdummyfont
  1154. \let\tclose=\indexdummyfont
  1155. \let\code=\indexdummyfont
  1156. \let\file=\indexdummyfont
  1157. \let\samp=\indexdummyfont
  1158. \let\kbd=\indexdummyfont
  1159. \let\key=\indexdummyfont
  1160. \let\var=\indexdummyfont
  1161. \let\TeX=\indexdummytex
  1162. \let\dots=\indexdummydots
  1163. % To define \realbackslash, we must make \ not be an escape.
  1164. % We must first make another character (@) an escape
  1165. % so we do not become unable to do a definition.
  1166. {\catcode`\@=0 \catcode`\\=\other
  1167. @gdef@realbackslash{\}}
  1168. \let\indexbackslash=0  %overridden during \printindex.
  1169. \def\doind #1#2{%
  1170. {\count10=\lastpenalty %
  1171. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1172. \escapechar=`\\%
  1173. {\let\folio=0% Expand all macros now EXCEPT \folio
  1174. \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
  1175. % so it will be output as is; and it will print as backslash in the indx.
  1176. % Now process the index-string once, with all font commands turned off,
  1177. % to get the string to sort the index by.
  1178. {\indexnofonts
  1179. \xdef\temp1{#2}%
  1180. % Now produce the complete index entry.  We process the index-string again,
  1181. % this time with font commands expanded, to get what to print in the index.
  1182. \edef\temp{%
  1183. \write \csname#1indfile\endcsname{%
  1184. \realbackslash entry {\temp1}{\folio}{#2}}}%
  1185. \temp }%
  1186. }\penalty\count10}}
  1187. \def\dosubind #1#2#3{%
  1188. {\count10=\lastpenalty %
  1189. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1190. \escapechar=`\\%
  1191. {\let\folio=0%
  1192. \def\rawbackslashxx{\indexbackslash}%
  1193. % Now process the index-string once, with all font commands turned off,
  1194. % to get the string to sort the index by.
  1195. {\indexnofonts
  1196. \xdef\temp1{#2 #3}%
  1197. % Now produce the complete index entry.  We process the index-string again,
  1198. % this time with font commands expanded, to get what to print in the index.
  1199. \edef\temp{%
  1200. \write \csname#1indfile\endcsname{%
  1201. \realbackslash entry {\temp1}{\folio}{#2}{#3}}}%
  1202. \temp }%
  1203. }\penalty\count10}}
  1204. % The index entry written in the file actually looks like
  1205. %  \entry {sortstring}{page}{topic}
  1206. %  \entry {sortstring}{page}{topic}{subtopic}
  1207. % The texindex program reads in these files and writes files
  1208. % containing these kinds of lines:
  1209. %  \initial {c}
  1210. %     before the first topic whose initial is c
  1211. %  \entry {topic}{pagelist}
  1212. %     for a topic that is used without subtopics
  1213. %  \primary {topic}
  1214. %     for the beginning of a topic that is used with subtopics
  1215. %  \secondary {subtopic}{pagelist}
  1216. %     for each subtopic.
  1217. % Define the user-accessible indexing commands 
  1218. % @findex, @vindex, @kindex, @cindex.
  1219. \def\findex {\fnindex}
  1220. \def\kindex {\kyindex}
  1221. \def\cindex {\cpindex}
  1222. \def\vindex {\vrindex}
  1223. \def\tindex {\tpindex}
  1224. \def\pindex {\pgindex}
  1225. \def\cindexsub {\begingroup\obeylines\cindexsub}
  1226. {\obeylines %
  1227. \gdef\cindexsub "#1" #2^^M{\endgroup %
  1228. \dosubind{cp}{#2}{#1}}}
  1229. % Define the macros used in formatting output of the sorted index material.
  1230. % This is what you call to cause a particular index to get printed.
  1231. % Write
  1232. % @unnumbered Function Index
  1233. % @printindex fn
  1234. \def\printindex{\parsearg\doprintindex}
  1235. \def\doprintindex#1{%
  1236.   \tex
  1237.   \dobreak \chapheadingskip {10000}
  1238.   \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other
  1239.   \catcode`\$=\other\catcode`\_=\other
  1240.   \catcode`\~=\other
  1241.   % The following don't help, since the chars were translated
  1242.   % when the raw index was written, and their fonts were discarded
  1243.   % due to \indexnofonts.
  1244.   %\catcode`\"=\active
  1245.   %\catcode`\^=\active
  1246.   %\catcode`\_=\active
  1247.   %\catcode`\|=\active
  1248.   %\catcode`\<=\active
  1249.   %\catcode`\>=\active
  1250.   % %
  1251.   \def\indexbackslash{\rawbackslashxx}
  1252.   \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt
  1253.   \begindoublecolumns
  1254.   % See if the index file exists and is nonempty.
  1255.   \openin 1 \jobname.#1s
  1256.   \ifeof 1 
  1257.     % \enddoublecolumns gets confused if there is no text in the index,
  1258.     % and it loses the chapter title and the aux file entries for the
  1259.     % index.  The easiest way to prevent this problem is to make sure
  1260.     % there is some text.
  1261.     (Index is nonexistent)
  1262.     \else
  1263.     %
  1264.     % If the index file exists but is empty, then \openin leaves \ifeof
  1265.     % false.  We have to make TeX try to read something from the file, so
  1266.     % it can discover if there is anything in it.
  1267.     \read 1 to \temp
  1268.     \ifeof 1
  1269.       (Index is empty)
  1270.     \else
  1271.       \input \jobname.#1s
  1272.     \fi
  1273.   \fi
  1274.   \closein 1
  1275.   \enddoublecolumns
  1276.   \Etex
  1277. % These macros are used by the sorted index file itself.
  1278. % Change them to control the appearance of the index.
  1279. % Same as \bigskipamount except no shrink.
  1280. % \balancecolumns gets confused if there is any shrink.
  1281. \newskip\initialskipamount \initialskipamount 12pt plus4pt
  1282. \def\initial #1{%
  1283. {\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
  1284. \ifdim\lastskip<\initialskipamount
  1285. \removelastskip \penalty-200 \vskip \initialskipamount\fi
  1286. \line{\secbf#1\hfill}\kern 2pt\penalty10000}}
  1287. \def\entry #1#2{\begingroup
  1288.   \parfillskip=0in \parskip=0in \parindent=0in
  1289.   % Do not prefer a separate line ending with a hyphen to fewer lines.
  1290.   \finalhyphendemerits = 0
  1291.   % \hangindent is only relevant when the entry text and page number
  1292.   % don't both fit on one line.  In that case, bob suggests starting the
  1293.   % dots pretty far over on the line.  Unfortunately, a large
  1294.   % indentation looks wrong when the entry text itself is broken across
  1295.   % lines.  So we use a small indentation and put up with long leaders.
  1296.   % \hangafter is reset to 1 (which is the value we want) at the start
  1297.   % of each paragraph, so we need not do anything with that.
  1298.   \hangindent=2em
  1299.   % When the entry text needs to be broken, just fill out the first line
  1300.   % with blank space.
  1301.   \rightskip = 0pt plus1fil
  1302.   % Start a ``paragraph'' for the index entry so the line breaking
  1303.   % parameters we've set above will have an effect.
  1304.   \noindent
  1305.   % Insert the text of the index entry.  TeX will do line-breaking on it.
  1306.   #1%
  1307.   % If we must, put the page number on a line of its own, and fill out
  1308.   % this line with blank space.  (The \hfil is overwhelmed with the
  1309.   % fill leaders glue in \indexdotfill if the page number does fit.)
  1310.   \hfil\penalty50
  1311.   \null\nobreak\indexdotfill % Have leaders before the page number.
  1312.   % The `\ ' here is removed by the implicit \unskip that TeX does as
  1313.   % part of (the primitive) \par.  Without it, a spurious underfull
  1314.   % \hbox ensues.
  1315.   \ #2% The page number ends the paragraph.
  1316.   \par
  1317. \endgroup}
  1318. % Like \dotfill except takes at least 1 em.
  1319. \def\indexdotfill{\cleaders
  1320.   \hbox{$\mathsurround=0pt \mkern1.5mu . \mkern1.5mu$}\hskip 1em plus 1fill}
  1321. \def\primary #1{\line{#1\hfil}}
  1322. \newskip\secondaryindent \secondaryindent=0.5cm
  1323. \def\secondary #1#2{
  1324. {\parfillskip=0in \parskip=0in
  1325. \hangindent =1in \hangafter=1
  1326. \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
  1327. %% Define two-column mode, which is used in indexes.
  1328. %% Adapted from the TeXbook, page 416.
  1329. \catcode `\@=11
  1330. \newbox\partialpage
  1331. \newdimen\doublecolumnhsize
  1332. \newdimen\availdimen@
  1333. \def\begindoublecolumns{\begingroup
  1334.   % Grab any single-column material above us.
  1335.   \output = {\global\setbox\partialpage
  1336.     =\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}%
  1337.   \eject
  1338.   % Now switch to the double-column output routine.
  1339.   \output={\doublecolumnout}%
  1340.   % Change the page size parameters.  We could do this once outside this
  1341.   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
  1342.   % format, but then we repeat the same computation.  Repeating a couple
  1343.   % of assignments once per index is clearly meaningless for the
  1344.   % execution time, so we may as well do it once.
  1345.   % First we halve the line length, less a little for the gutter between
  1346.   % the columns.  We compute the gutter based on the line length, so it
  1347.   % changes automatically with the paper format.  The magic constant
  1348.   % below is chosen so that the gutter has the same value (well, +- <
  1349.   % 1pt) as it did when we hard-coded it.
  1350.   % We put the result in a separate register, \doublecolumhsize, so we
  1351.   % can restore it in \pagesofar, after \hsize itself has (potentially)
  1352.   % been clobbered.
  1353.   \doublecolumnhsize = \hsize
  1354.     \advance\doublecolumnhsize by -.04154\hsize
  1355.     \divide\doublecolumnhsize by 2
  1356.   \hsize = \doublecolumnhsize
  1357.   % Double the \vsize as well.  (We don't need a separate register here,
  1358.   % since nobody clobbers \vsize.)
  1359.   \vsize = 2\vsize
  1360. \def\enddoublecolumns{\output={\balancecolumns}\eject
  1361.   \endgroup \pagegoal=\vsize}
  1362. \def\doublecolumnout{\splittopskip=\topskip \splitmaxdepth=\maxdepth
  1363.   \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
  1364.   \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
  1365.   \onepageout\pagesofar \unvbox255 \penalty\outputpenalty}
  1366. \def\pagesofar{\unvbox\partialpage %
  1367.   \hsize=\doublecolumnhsize % have to restore this since output routine
  1368. %          changes it to set cropmarks (P. A. MacKay, 12 Nov. 1986)
  1369.   \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}}
  1370. \def\balancecolumns{%
  1371. % Unset the glue.
  1372.   \setbox255=\vbox{\unvbox255}
  1373.   \dimen@=\ht255
  1374.   \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  1375.   \divide\dimen@ by2
  1376.   \availdimen@=\pageheight \advance\availdimen@ by-\ht\partialpage
  1377. % If the remaining data is too big for one page,
  1378. % output one page normally, then work with what remains.
  1379.   \ifdim \dimen@>\availdimen@
  1380.      \splittopskip=\topskip \splitmaxdepth=\maxdepth
  1381.      \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
  1382.      \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
  1383.      \onepageout\pagesofar
  1384. % Recompute size of what remains, in case we just output some of it.
  1385.   \dimen@=\ht255
  1386.   \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  1387.   \divide\dimen@ by2
  1388.   \fi
  1389.   \setbox0=\vbox{\unvbox255}
  1390.   \splittopskip=\topskip
  1391.   {\vbadness=10000 \loop \global\setbox3=\copy0
  1392.     \global\setbox1=\vsplit3 to\dimen@
  1393.     \ifdim\ht3>\dimen@ \global\advance\dimen@ by1pt \repeat}
  1394.   \setbox0=\vbox to\dimen@{\unvbox1}  \setbox2=\vbox to\dimen@{\unvbox3}
  1395.   \pagesofar}
  1396. \catcode `\@=\other
  1397. \message{sectioning,}
  1398. % Define chapters, sections, etc.
  1399. \newcount \chapno
  1400. \newcount \secno        \secno=0
  1401. \newcount \subsecno     \subsecno=0
  1402. \newcount \subsubsecno  \subsubsecno=0
  1403. % This counter is funny since it counts through charcodes of letters A, B, ...
  1404. \newcount \appendixno  \appendixno = `\@
  1405. \def\appendixletter{\char\the\appendixno}
  1406. \newwrite \contentsfile
  1407. % This is called from \setfilename.
  1408. \def\opencontents{\openout \contentsfile = \jobname.toc}
  1409. % Each @chapter defines this as the name of the chapter.
  1410. % page headings and footings can use it.  @section does likewise
  1411. \def\thischapter{} \def\thissection{}
  1412. \def\seccheck#1{\if \pageno<0 %
  1413. \errmessage{@#1 not allowed after generating table of contents}\fi
  1414. \def\chapternofonts{%
  1415. \let\rawbackslash=\relax%
  1416. \let\frenchspacing=\relax%
  1417. \def\result{\realbackslash result}
  1418. \def\equiv{\realbackslash equiv}
  1419. \def\expansion{\realbackslash expansion}
  1420. \def\print{\realbackslash print}
  1421. \def\TeX{\realbackslash TeX}
  1422. \def\dots{\realbackslash dots}
  1423. \def\copyright{\realbackslash copyright}
  1424. \def\tt{\realbackslash tt}
  1425. \def\bf{\realbackslash bf }
  1426. \def\w{\realbackslash w}
  1427. \def\less{\realbackslash less}
  1428. \def\gtr{\realbackslash gtr}
  1429. \def\hat{\realbackslash hat}
  1430. \def\char{\realbackslash char}
  1431. \def\tclose##1{\realbackslash tclose {##1}}
  1432. \def\code##1{\realbackslash code {##1}}
  1433. \def\samp##1{\realbackslash samp {##1}}
  1434. \def\r##1{\realbackslash r {##1}}
  1435. \def\b##1{\realbackslash b {##1}}
  1436. \def\key##1{\realbackslash key {##1}}
  1437. \def\file##1{\realbackslash file {##1}}
  1438. \def\kbd##1{\realbackslash kbd {##1}}
  1439. % These are redefined because @smartitalic wouldn't work inside xdef.
  1440. \def\i##1{\realbackslash i {##1}}
  1441. \def\cite##1{\realbackslash cite {##1}}
  1442. \def\var##1{\realbackslash var {##1}}
  1443. \def\emph##1{\realbackslash emph {##1}}
  1444. \def\dfn##1{\realbackslash dfn {##1}}
  1445. \def\thischaptername{No Chapter Title}
  1446. \outer\def\chapter{\parsearg\chapterzzz}
  1447. \def\chapterzzz #1{\seccheck{chapter}%
  1448. \secno=0 \subsecno=0 \subsubsecno=0
  1449. \global\advance \chapno by 1 \message{Chapter \the\chapno}%
  1450. \chapmacro {#1}{\the\chapno}%
  1451. \gdef\thissection{#1}%
  1452. \gdef\thischaptername{#1}%
  1453. % We don't substitute the actual chapter name into \thischapter
  1454. % because we don't want its macros evaluated now.
  1455. \xdef\thischapter{Chapter \the\chapno: \noexpand\thischaptername}%
  1456. {\chapternofonts%
  1457. \edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}%
  1458. \escapechar=`\\%
  1459. \write \contentsfile \temp  %
  1460. \donoderef %
  1461. \global\let\section = \numberedsec
  1462. \global\let\subsection = \numberedsubsec
  1463. \global\let\subsubsection = \numberedsubsubsec
  1464. \outer\def\appendix{\parsearg\appendixzzz}
  1465. \def\appendixzzz #1{\seccheck{appendix}%
  1466. \secno=0 \subsecno=0 \subsubsecno=0
  1467. \global\advance \appendixno by 1 \message{Appendix \appendixletter}%
  1468. \chapmacro {#1}{Appendix \appendixletter}%
  1469. \gdef\thissection{#1}%
  1470. \gdef\thischaptername{#1}%
  1471. \xdef\thischapter{Appendix \appendixletter: \noexpand\thischaptername}%
  1472. {\chapternofonts%
  1473. \edef\temp{{\realbackslash chapentry 
  1474.   {#1}{Appendix \appendixletter}{\noexpand\folio}}}%
  1475. \escapechar=`\\%
  1476. \write \contentsfile \temp  %
  1477. \appendixnoderef %
  1478. \global\let\section = \appendixsec
  1479. \global\let\subsection = \appendixsubsec
  1480. \global\let\subsubsection = \appendixsubsubsec
  1481. \outer\def\top{\parsearg\unnumberedzzz}
  1482. \outer\def\unnumbered{\parsearg\unnumberedzzz}
  1483. \def\unnumberedzzz #1{\seccheck{unnumbered}%
  1484. \secno=0 \subsecno=0 \subsubsecno=0 \message{(#1)}
  1485. \unnumbchapmacro {#1}%
  1486. \gdef\thischapter{#1}\gdef\thissection{#1}%
  1487. {\chapternofonts%
  1488. \edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}%
  1489. \escapechar=`\\%
  1490. \write \contentsfile \temp  %
  1491. \unnumbnoderef %
  1492. \global\let\section = \unnumberedsec
  1493. \global\let\subsection = \unnumberedsubsec
  1494. \global\let\subsubsection = \unnumberedsubsubsec
  1495. \outer\def\numberedsec{\parsearg\seczzz}
  1496. \def\seczzz #1{\seccheck{section}%
  1497. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1498. \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
  1499. {\chapternofonts%
  1500. \edef\temp{{\realbackslash secentry %
  1501. {#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}%
  1502. \escapechar=`\\%
  1503. \write \contentsfile \temp %
  1504. \donoderef %
  1505. \penalty 10000 %
  1506. \outer\def\appendixsection{\parsearg\appendixsectionzzz}
  1507. \outer\def\appendixsec{\parsearg\appendixsectionzzz}
  1508. \def\appendixsectionzzz #1{\seccheck{appendixsection}%
  1509. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1510. \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
  1511. {\chapternofonts%
  1512. \edef\temp{{\realbackslash secentry %
  1513. {#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}%
  1514. \escapechar=`\\%
  1515. \write \contentsfile \temp %
  1516. \appendixnoderef %
  1517. \penalty 10000 %
  1518. \outer\def\unnumberedsec{\parsearg\unnumberedseczzz}
  1519. \def\unnumberedseczzz #1{\seccheck{unnumberedsec}%
  1520. \plainsecheading {#1}\gdef\thissection{#1}%
  1521. {\chapternofonts%
  1522. \edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}%
  1523. \escapechar=`\\%
  1524. \write \contentsfile \temp %
  1525. \unnumbnoderef %
  1526. \penalty 10000 %
  1527. \outer\def\numberedsubsec{\parsearg\numberedsubseczzz}
  1528. \def\numberedsubseczzz #1{\seccheck{subsection}%
  1529. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1530. \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
  1531. {\chapternofonts%
  1532. \edef\temp{{\realbackslash subsecentry %
  1533. {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1534. \escapechar=`\\%
  1535. \write \contentsfile \temp %
  1536. \donoderef %
  1537. \penalty 10000 %
  1538. \outer\def\appendixsubsec{\parsearg\appendixsubseczzz}
  1539. \def\appendixsubseczzz #1{\seccheck{appendixsubsec}%
  1540. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1541. \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
  1542. {\chapternofonts%
  1543. \edef\temp{{\realbackslash subsecentry %
  1544. {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1545. \escapechar=`\\%
  1546. \write \contentsfile \temp %
  1547. \appendixnoderef %
  1548. \penalty 10000 %
  1549. \outer\def\unnumberedsubsec{\parsearg\unnumberedsubseczzz}
  1550. \def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}%
  1551. \plainsecheading {#1}\gdef\thissection{#1}%
  1552. {\chapternofonts%
  1553. \edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}%
  1554. \escapechar=`\\%
  1555. \write \contentsfile \temp %
  1556. \unnumbnoderef %
  1557. \penalty 10000 %
  1558. \outer\def\numberedsubsubsec{\parsearg\numberedsubsubseczzz}
  1559. \def\numberedsubsubseczzz #1{\seccheck{subsubsection}%
  1560. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1561. \subsubsecheading {#1}
  1562.   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1563. {\chapternofonts%
  1564. \edef\temp{{\realbackslash subsubsecentry %
  1565.   {#1}
  1566.   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}
  1567.   {\noexpand\folio}}}%
  1568. \escapechar=`\\%
  1569. \write \contentsfile \temp %
  1570. \donoderef %
  1571. \penalty 10000 %
  1572. \outer\def\appendixsubsubsec{\parsearg\appendixsubsubseczzz}
  1573. \def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}%
  1574. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1575. \subsubsecheading {#1}
  1576.   {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1577. {\chapternofonts%
  1578. \edef\temp{{\realbackslash subsubsecentry{#1}%
  1579.   {\appendixletter}
  1580.   {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%
  1581. \escapechar=`\\%
  1582. \write \contentsfile \temp %
  1583. \appendixnoderef %
  1584. \penalty 10000 %
  1585. \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  1586. \def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}%
  1587. \plainsecheading {#1}\gdef\thissection{#1}%
  1588. {\chapternofonts%
  1589. \edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}%
  1590. \escapechar=`\\%
  1591. \write \contentsfile \temp %
  1592. \unnumbnoderef %
  1593. \penalty 10000 %
  1594. % These are variants which are not "outer", so they can appear in @ifinfo.
  1595. % Actually, they should now be obsolete; ordinary section commands should work.
  1596. \def\infotop{\parsearg\unnumberedzzz}
  1597. \def\infounnumbered{\parsearg\unnumberedzzz}
  1598. \def\infounnumberedsec{\parsearg\unnumberedseczzz}
  1599. \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
  1600. \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  1601. \def\infoappendix{\parsearg\appendixzzz}
  1602. \def\infoappendixsec{\parsearg\appendixseczzz}
  1603. \def\infoappendixsubsec{\parsearg\appendixsubseczzz}
  1604. \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
  1605. \def\infochapter{\parsearg\chapterzzz}
  1606. \def\infosection{\parsearg\sectionzzz}
  1607. \def\infosubsection{\parsearg\subsectionzzz}
  1608. \def\infosubsubsection{\parsearg\subsubsectionzzz}
  1609. % These macros control what the section commands do, according
  1610. % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
  1611. % Define them by default for a numbered chapter.
  1612. \global\let\section = \numberedsec
  1613. \global\let\subsection = \numberedsubsec
  1614. \global\let\subsubsection = \numberedsubsubsec
  1615. % Define @majorheading, @heading and @subheading
  1616. % NOTE on use of \vbox for chapter headings, section headings, and
  1617. % such:
  1618. %    1) We use \vbox rather than the earlier \line to permit
  1619. %       overlong headings to fold.
  1620. %    2) \hyphenpenalty is set to 10000 because hyphenation in a
  1621. %       heading is obnoxious; this forbids it.
  1622. %       3) Likewise, headings look best if no \parindent is used, and
  1623. %          if justification is not attempted.  Hence \raggedright.
  1624. \def\majorheading{\parsearg\majorheadingzzz}
  1625. \def\majorheadingzzz #1{%
  1626. {\advance\chapheadingskip by 10pt \chapbreak }%
  1627. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1628.                   \parindent=0pt\raggedright
  1629.                   \rm #1\hfill}}\bigskip \par\penalty 200}
  1630. \def\chapheading{\parsearg\chapheadingzzz}
  1631. \def\chapheadingzzz #1{\chapbreak %
  1632. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1633.                   \parindent=0pt\raggedright
  1634.                   \rm #1\hfill}}\bigskip \par\penalty 200}
  1635. \def\heading{\parsearg\secheadingi}
  1636. \def\subheading{\parsearg\subsecheadingi}
  1637. \def\subsubheading{\parsearg\subsubsecheadingi}
  1638. % These macros generate a chapter, section, etc. heading only
  1639. % (including whitespace, linebreaking, etc. around it),
  1640. % given all the information in convenient, parsed form.
  1641. %%% Args are the skip and penalty (usually negative)
  1642. \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
  1643. \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
  1644. %%% Define plain chapter starts, and page on/off switching for it
  1645. % Parameter controlling skip before chapter headings (if needed)
  1646. \newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt
  1647. \def\chapbreak{\dobreak \chapheadingskip {-4000}}
  1648. \def\chappager{\par\vfill\supereject}
  1649. \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
  1650. \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
  1651. \def\CHAPPAGoff{
  1652. \global\let\pchapsepmacro=\chapbreak
  1653. \global\let\pagealignmacro=\chappager}
  1654. \def\CHAPPAGon{
  1655. \global\let\pchapsepmacro=\chappager
  1656. \global\let\pagealignmacro=\chappager
  1657. \global\def\HEADINGSon{\HEADINGSsingle}}
  1658. \def\CHAPPAGodd{
  1659. \global\let\pchapsepmacro=\chapoddpage
  1660. \global\let\pagealignmacro=\chapoddpage
  1661. \global\def\HEADINGSon{\HEADINGSdouble}}
  1662. \CHAPPAGon
  1663. \def\CHAPFplain{
  1664. \global\let\chapmacro=\chfplain
  1665. \global\let\unnumbchapmacro=\unnchfplain}
  1666. \def\chfplain #1#2{%
  1667.   \pchapsepmacro
  1668.     \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1669.                      \parindent=0pt\raggedright
  1670.                      \rm #2\enspace #1}%
  1671.   \bigskip
  1672.   \penalty5000
  1673. \def\unnchfplain #1{%
  1674. \pchapsepmacro %
  1675. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1676.                   \parindent=0pt\raggedright
  1677.                   \rm #1\hfill}}\bigskip \par\penalty 10000 %
  1678. \CHAPFplain % The default
  1679. \def\unnchfopen #1{%
  1680. \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1681.                        \parindent=0pt\raggedright
  1682.                        \rm #1\hfill}}\bigskip \par\penalty 10000 %
  1683. \def\chfopen #1#2{\chapoddpage {\chapfonts
  1684. \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
  1685. \par\penalty 5000 %
  1686. \def\CHAPFopen{
  1687. \global\let\chapmacro=\chfopen
  1688. \global\let\unnumbchapmacro=\unnchfopen}
  1689. % Parameter controlling skip before section headings.
  1690. \newskip \subsecheadingskip  \subsecheadingskip = 17pt plus 8pt minus 4pt
  1691. \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
  1692. \newskip \secheadingskip  \secheadingskip = 21pt plus 8pt minus 4pt
  1693. \def\secheadingbreak{\dobreak \secheadingskip {-1000}}
  1694. % @paragraphindent  is defined for the Info formatting commands only.
  1695. \let\paragraphindent=\comment
  1696. % Section fonts are the base font at magstep2, which produces
  1697. % a size a bit more than 14 points in the default situation.    
  1698. \def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}}
  1699. \def\plainsecheading #1{\secheadingi {#1}}
  1700. \def\secheadingi #1{{\advance \secheadingskip by \parskip %
  1701. \secheadingbreak}%
  1702. {\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1703.                  \parindent=0pt\raggedright
  1704.                  \rm #1\hfill}}%
  1705. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  1706. % Subsection fonts are the base font at magstep1, 
  1707. % which produces a size of 12 points.
  1708. \def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}}
  1709. \def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip %
  1710. \subsecheadingbreak}%
  1711. {\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1712.                      \parindent=0pt\raggedright
  1713.                      \rm #1\hfill}}%
  1714. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  1715. \def\subsubsecfonts{\subsecfonts} % Maybe this should change:
  1716.                   % Perhaps make sssec fonts scaled
  1717.                   % magstep half
  1718. \def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}}
  1719. \def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip %
  1720. \subsecheadingbreak}%
  1721. {\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1722.                        \parindent=0pt\raggedright
  1723.                        \rm #1\hfill}}%
  1724. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000}
  1725. \message{toc printing,}
  1726. % Finish up the main text and prepare to read what we've written
  1727. % to \contentsfile.
  1728. \newskip\contentsrightmargin \contentsrightmargin=1in
  1729. \def\startcontents#1{%
  1730.    \pagealignmacro
  1731.    \immediate\closeout \contentsfile
  1732.    \ifnum \pageno>0
  1733.       \pageno = -1        % Request roman numbered pages.
  1734.    \fi
  1735.    % Don't need to put `Contents' or `Short Contents' in the headline. 
  1736.    % It is abundantly clear what they are.
  1737.    \unnumbchapmacro{#1}\def\thischapter{}%
  1738.    \begingroup           % Set up to handle contents files properly.
  1739.       \catcode`\\=0  \catcode`\{=1  \catcode`\}=2  \catcode`\@=11
  1740.       \raggedbottom             % Worry more about breakpoints than the bottom.
  1741.       \advance\hsize by -\contentsrightmargin % Don't use the full line length.
  1742. % Normal (long) toc.
  1743. \outer\def\contents{%
  1744.    \startcontents{Table of Contents}%
  1745.       \input \jobname.toc
  1746.    \endgroup
  1747.    \vfill \eject
  1748. % And just the chapters.
  1749. \outer\def\summarycontents{%
  1750.    \startcontents{Short Contents}%
  1751.       %
  1752.       \let\chapentry = \shortchapentry
  1753.       \let\unnumbchapentry = \shortunnumberedentry
  1754.       % We want a true roman here for the page numbers.
  1755.       \secfonts
  1756.       \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
  1757.       \rm
  1758.       \advance\baselineskip by 1pt % Open it up a little.
  1759.       \def\secentry ##1##2##3##4{}
  1760.       \def\unnumbsecentry ##1##2{}
  1761.       \def\subsecentry ##1##2##3##4##5{}
  1762.       \def\unnumbsubsecentry ##1##2{}
  1763.       \def\subsubsecentry ##1##2##3##4##5##6{}
  1764.       \def\unnumbsubsubsecentry ##1##2{}
  1765.       \input \jobname.toc
  1766.    \endgroup
  1767.    \vfill \eject
  1768. \let\shortcontents = \summarycontents
  1769. % These macros generate individual entries in the table of contents.
  1770. % The first argument is the chapter or section name.
  1771. % The last argument is the page number.
  1772. % The arguments in between are the chapter number, section number, ...
  1773. % Chapter-level things, for both the long and short contents.
  1774. \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
  1775. % See comments in \dochapentry re vbox and related settings
  1776. \def\shortchapentry#1#2#3{%
  1777.    \vbox{\hyphenpenalty=10000\tolerance=5000
  1778.     \parindent=0pt\strut\raggedright
  1779.     {\shortchaplabel{#2}\labelspace #1}\dotfill\doshortpageno{#3}}%
  1780. % Typeset the label for a chapter or appendix for the short contents.
  1781. % The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter.
  1782. % We could simplify the code here by writing out an \appendixentry
  1783. % command in the toc file for appendices, instead of using \chapentry
  1784. % for both, but it doesn't seem worth it.
  1785. \setbox0 = \hbox{\shortcontrm Appendix }
  1786. \newdimen\shortappendixwidth \shortappendixwidth = \wd0
  1787. \def\shortchaplabel#1{%
  1788.   % We typeset #1 in a box of constant width, regardless of the text of
  1789.   % #1, so the chapter titles will come out aligned.
  1790.   \setbox0 = \hbox{#1}%
  1791.   \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi
  1792.   % This space should be plenty, since a single number is .5em, and the
  1793.   % widest letter (M) is 1em, at least in the Computer Modern fonts.
  1794.   % (This space doesn't include the extra space that gets added after
  1795.   % the label; that gets put in in \shortchapentry above.)
  1796.   \advance\dimen0 by 1.1em
  1797.   \hbox to \dimen0{#1\hfil}%
  1798. \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
  1799. \def\shortunnumberedentry#1#2{%
  1800.    \vbox{\hyphenpenalty=10000\tolerance=5000
  1801.     \parindent=0pt\strut\raggedright
  1802.     #1\dotfill\doshortpageno{#2}}%
  1803. % Sections.
  1804. \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
  1805. \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
  1806. % Subsections.
  1807. \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
  1808. \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
  1809. % And subsubsections.
  1810. \def\subsubsecentry#1#2#3#4#5#6{%
  1811.   \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
  1812. \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
  1813. % This parameter controls the indentation of the various levels.
  1814. \newdimen\tocindent \tocindent = 3pc
  1815. % Now for the actual typesetting. In all these, #1 is the text and #2 is the 
  1816. % page number.
  1817. % If the toc has to be broken over pages, we would want to be at chapters 
  1818. % if at all possible; hence the \penalty.
  1819. \def\dochapentry#1#2{%
  1820.    \penalty-300 \vskip\baselineskip
  1821.    % This \vbox (and similar ones in dosecentry etc.) used to be a
  1822.    % \line; changed to permit linebreaks for long headings.  See
  1823.    % comments above \majorheading.  Here we also use \strut to
  1824.    % keep the top end of the vbox from jamming up against the previous
  1825.    % entry in the table of contents.
  1826.    \vbox{\chapentryfonts
  1827.      \hyphenpenalty=10000\tolerance=5000 % this line and next introduced
  1828.      \parindent=0pt\strut\raggedright    % with \line -> \vbox change
  1829.      #1\dotfill
  1830.      \dopageno{#2}}%
  1831.    \nobreak\vskip .25\baselineskip
  1832. \def\dosecentry#1#2{%
  1833.    \vbox{\secentryfonts \leftskip=\tocindent
  1834.     \hyphenpenalty=10000\tolerance=5000
  1835.     \parindent=0pt\strut\raggedright #1\dotfill
  1836.     \dopageno{#2}}%
  1837. \def\dosubsecentry#1#2{%
  1838.    \vbox{\subsecentryfonts \leftskip=2\tocindent
  1839.     \hyphenpenalty=10000\tolerance=5000
  1840.     \parindent=0pt\strut\raggedright #1\dotfill
  1841.     \dopageno{#2}}%
  1842. \def\dosubsubsecentry#1#2{%
  1843.    \vbox{\subsubsecentryfonts \leftskip=3\tocindent
  1844.     \hyphenpenalty=10000\tolerance=5000
  1845.     \parindent=0pt\strut\raggedright #1\dotfill
  1846.     \dopageno{#2}}%
  1847. % Space between chapter (or whatever) number and the title.
  1848. \def\labelspace{\hskip1em \relax}
  1849. \def\dopageno#1{{\rm #1}}
  1850. \def\doshortpageno#1{{\rm #1}}
  1851. \def\chapentryfonts{\secfonts \rm}
  1852. \def\secentryfonts{\textfonts}
  1853. \let\subsecentryfonts = \textfonts
  1854. \let\subsubsecentryfonts = \textfonts
  1855. \message{environments,}
  1856. % Since these characters are used in examples, it should be an even number of 
  1857. % \tt widths. Each \tt character is 1en, so two makes it 1em.
  1858. % Furthermore, these definitions must come after we define our fonts.
  1859. \newbox\dblarrowbox    \newbox\longdblarrowbox
  1860. \newbox\pushcharbox    \newbox\bullbox
  1861. \newbox\equivbox       \newbox\errorbox
  1862. \let\ptexequiv = \equiv
  1863. %{\tentt
  1864. %\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
  1865. %\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
  1866. %\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
  1867. %\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
  1868. % Adapted from the manmac format (p.420 of TeXbook)
  1869. %\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
  1870. %                                      depth .1ex\hfil}
  1871. \def\point{$\star$}
  1872. \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
  1873. \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
  1874. \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
  1875. \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
  1876. % Adapted from the TeXbook's \boxit.
  1877. {\tentt \global\dimen0 = 3em}% Width of the box.
  1878. \dimen2 = .55pt % Thickness of rules
  1879. % The text. (`r' is open on the right, `e' somewhat less so on the left.)
  1880. \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
  1881. \global\setbox\errorbox=\hbox to \dimen0{\hfil
  1882.    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
  1883.    \advance\hsize by -2\dimen2 % Rules.
  1884.    \vbox{
  1885.       \hrule height\dimen2
  1886.       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
  1887.          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
  1888.          \kern3pt\vrule width\dimen2}% Space to right.
  1889.       \hrule height\dimen2}
  1890.     \hfil}
  1891. % The @error{} command.
  1892. \def\error{\leavevmode\lower.7ex\copy\errorbox}
  1893. % @tex ... @end tex    escapes into raw Tex temporarily.
  1894. % One exception: @ is still an escape character, so that @end tex works.
  1895. % But \@ or @@ will get a plain tex @ character.
  1896. \def\tex{\begingroup
  1897. \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
  1898. \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
  1899. \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
  1900. \catcode `\%=14
  1901. \catcode 43=12
  1902. \catcode`\"=12
  1903. \catcode`\==12
  1904. \catcode`\|=12
  1905. \catcode`\<=12
  1906. \catcode`\>=12
  1907. \escapechar=`\\
  1908. \let\{=\ptexlbrace
  1909. \let\}=\ptexrbrace
  1910. \let\.=\ptexdot
  1911. \let\*=\ptexstar
  1912. \let\dots=\ptexdots
  1913. \def\@{@}%
  1914. \let\bullet=\ptexbullet
  1915. \let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl
  1916. \let\L=\ptexL
  1917. \let\Etex=\endgroup}
  1918. % Define @lisp ... @endlisp.
  1919. % @lisp does a \begingroup so it can rebind things,
  1920. % including the definition of @endlisp (which normally is erroneous).
  1921. % Amount to narrow the margins by for @lisp.
  1922. \newskip\lispnarrowing \lispnarrowing=0.4in
  1923. % This is the definition that ^M gets inside @lisp
  1924. % phr: changed space to \null, to avoid overfull hbox problems.
  1925. {\obeyspaces%
  1926. \gdef\lisppar{\null\endgraf}}
  1927. % Cause \obeyspaces to make each Space cause a word-separation
  1928. % rather than the default which is that it acts punctuation.
  1929. % This is because space in tt font looks funny.
  1930. {\obeyspaces %
  1931. \gdef\sepspaces{\def {\ }}}
  1932. % This space is always present above and below environments.
  1933. \newskip\envskipamount \envskipamount = 0pt
  1934. % Make spacing and below environment symmetrical.
  1935. \def\aboveenvbreak{{\advance\envskipamount by \parskip
  1936. \endgraf \ifdim\lastskip<\envskipamount
  1937. \removelastskip \penalty-50 \vskip\envskipamount \fi}}
  1938. \let\afterenvbreak = \aboveenvbreak
  1939. % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins.
  1940. \let\nonarrowing=\relax
  1941. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1942. % \cartouche: draw rectangle w/rounded corners around argument
  1943. \font\circle=lcircle10
  1944. \newdimen\circthick
  1945. \newdimen\cartouter\newdimen\cartinner
  1946. \newskip\normbskip\newskip\normpskip\newskip\normlskip
  1947. \circthick=\fontdimen8\circle
  1948. \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
  1949. \def\ctr{{\hskip 6pt\circle\char'010}}
  1950. \def\cbl{{\circle\char'012\hskip -6pt}}
  1951. \def\cbr{{\hskip 6pt\circle\char'011}}
  1952. \def\carttop{\hbox to \cartouter{\hskip\lskip
  1953.     \ctl\leaders\hrule height\circthick\hfil\ctr
  1954.     \hskip\rskip}}
  1955. \def\cartbot{\hbox to \cartouter{\hskip\lskip
  1956.     \cbl\leaders\hrule height\circthick\hfil\cbr
  1957.     \hskip\rskip}}
  1958. \newskip\lskip\newskip\rskip
  1959. \long\def\cartouche{%
  1960. \begingroup
  1961.     \lskip=\leftskip \rskip=\rightskip
  1962.     \leftskip=0pt\rightskip=0pt %we want these *outside*.
  1963.     \cartinner=\hsize \advance\cartinner by-\lskip 
  1964.                \advance\cartinner by-\rskip
  1965.     \cartouter=\hsize
  1966.     \advance\cartouter by 18pt % allow for 3pt kerns on either
  1967. %                     side, and for 6pt waste from
  1968. %                     each corner char
  1969.     \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
  1970.     % Flag to tell @lisp, etc., not to narrow margin.
  1971.     \let\nonarrowing=\comment
  1972.     \vbox\bgroup
  1973.         \baselineskip=0pt\parskip=0pt\lineskip=0pt
  1974.         \carttop
  1975.         \hbox\bgroup
  1976.             \hskip\lskip
  1977.             \vrule\kern3pt
  1978.             \vbox\bgroup
  1979.                 \hsize=\cartinner
  1980.                 \kern3pt
  1981.                 \begingroup
  1982.                     \baselineskip=\normbskip
  1983.                     \lineskip=\normlskip
  1984.                     \parskip=\normpskip
  1985.                     \vskip -\parskip
  1986. \def\Ecartouche{%
  1987.                 \endgroup
  1988.                 \kern3pt
  1989.             \egroup
  1990.             \kern3pt\vrule
  1991.             \hskip\rskip
  1992.         \egroup
  1993.         \cartbot
  1994.     \egroup
  1995. \endgroup
  1996. \def\lisp{\aboveenvbreak
  1997. \begingroup\inENV % This group ends at the end of the @lisp body
  1998. \hfuzz=12truept % Don't be fussy
  1999. % Make spaces be word-separators rather than space tokens.
  2000. \sepspaces %
  2001. % Single space lines
  2002. \singlespace %
  2003. % The following causes blank lines not to be ignored
  2004. % by adding a space to the end of each line.
  2005. \let\par=\lisppar
  2006. \def\Elisp{\endgroup\afterenvbreak}%
  2007. \parskip=0pt
  2008. % @cartouche defines \nonarrowing to inhibit narrowing
  2009. % at next level down.
  2010. \ifx\nonarrowing\relax
  2011. \advance \leftskip by \lispnarrowing
  2012. \exdentamount=\lispnarrowing
  2013. \let\exdent=\nofillexdent
  2014. \let\nonarrowing=\relax
  2015. \parindent=0pt
  2016. \obeyspaces \obeylines \tt \rawbackslash
  2017. \gobble
  2018. % Define the \E... control sequence only if we are inside the
  2019. % environment, so the error checking in \end will work.
  2020. % We must call \lisp last in the definition, since it reads the
  2021. % return following the @example (or whatever) command.
  2022. \def\example{\begingroup \def\Eexample{\Elisp\endgroup}\lisp}
  2023. \def\smallexample{\begingroup \def\Esmallexample{\Elisp\endgroup}\lisp}
  2024. % Macro for 9 pt. examples, necessary to print with 5" lines.
  2025. % From Pavel@xerox.  This is not really used unless the
  2026. % @smallbook command is given.
  2027. \def\smalllispx{\aboveenvbreak\begingroup\inENV
  2028. %            This group ends at the end of the @lisp body
  2029. \hfuzz=12truept % Don't be fussy
  2030. % Make spaces be word-separators rather than space tokens.
  2031. \sepspaces %
  2032. % Single space lines
  2033. \singlespace %
  2034. % The following causes blank lines not to be ignored
  2035. % by adding a space to the end of each line.
  2036. \let\par=\lisppar
  2037. \def\Esmalllisp{\endgroup\afterenvbreak}%
  2038. %%%% Smaller baseline skip for small examples.
  2039. \baselineskip 10pt
  2040. \parskip=0pt
  2041. % @cartouche defines \nonarrowing to inhibit narrowing
  2042. % at next level down.
  2043. \ifx\nonarrowing\relax
  2044. \advance \leftskip by \lispnarrowing
  2045. \exdentamount=\lispnarrowing
  2046. \let\exdent=\nofillexdent
  2047. \let\nonarrowing=\relax
  2048. \parindent=0pt
  2049. \obeyspaces \obeylines \ninett \indexfonts \rawbackslash
  2050. \def\next##1{}\next}
  2051. % This is @display; same as @lisp except use roman font.
  2052. \def\display{\begingroup\inENV %This group ends at the end of the @display body
  2053. \aboveenvbreak
  2054. % Make spaces be word-separators rather than space tokens.
  2055. \sepspaces %
  2056. % Single space lines
  2057. \singlespace %
  2058. % The following causes blank lines not to be ignored
  2059. % by adding a space to the end of each line.
  2060. \let\par=\lisppar
  2061. \def\Edisplay{\endgroup\afterenvbreak}%
  2062. \parskip=0pt
  2063. % @cartouche defines \nonarrowing to inhibit narrowing
  2064. % at next level down.
  2065. \ifx\nonarrowing\relax
  2066. \advance \leftskip by \lispnarrowing
  2067. \exdentamount=\lispnarrowing
  2068. \let\exdent=\nofillexdent
  2069. \let\nonarrowing=\relax
  2070. \parindent=0pt
  2071. \obeyspaces \obeylines
  2072. \def\next##1{}\next}
  2073. % This is @format; same as @lisp except use roman font and don't narrow margins
  2074. \def\format{\begingroup\inENV %This group ends at the end of the @format body
  2075. \aboveenvbreak
  2076. % Make spaces be word-separators rather than space tokens.
  2077. \sepspaces %
  2078. \singlespace %
  2079. % The following causes blank lines not to be ignored
  2080. % by adding a space to the end of each line.
  2081. \let\par=\lisppar
  2082. \def\Eformat{\endgroup\afterenvbreak}
  2083. \parskip=0pt \parindent=0pt
  2084. \obeyspaces \obeylines
  2085. \def\next##1{}\next}
  2086. % @flushleft and @flushright
  2087. \def\flushleft{%
  2088. \begingroup\inENV %This group ends at the end of the @format body
  2089. \aboveenvbreak
  2090. % Make spaces be word-separators rather than space tokens.
  2091. \sepspaces %
  2092. % The following causes blank lines not to be ignored
  2093. % by adding a space to the end of each line.
  2094. % This also causes @ to work when the directive name
  2095. % is terminated by end of line.
  2096. \let\par=\lisppar
  2097. \def\Eflushleft{\endgroup\afterenvbreak}%
  2098. \parskip=0pt \parindent=0pt
  2099. \obeyspaces \obeylines
  2100. \def\next##1{}\next}
  2101. \def\flushright{%
  2102. \begingroup\inENV %This group ends at the end of the @format body
  2103. \aboveenvbreak
  2104. % Make spaces be word-separators rather than space tokens.
  2105. \sepspaces %
  2106. % The following causes blank lines not to be ignored
  2107. % by adding a space to the end of each line.
  2108. % This also causes @ to work when the directive name
  2109. % is terminated by end of line.
  2110. \let\par=\lisppar
  2111. \def\Eflushright{\endgroup\afterenvbreak}%
  2112. \parskip=0pt \parindent=0pt
  2113. \advance \leftskip by 0pt plus 1fill
  2114. \obeyspaces \obeylines
  2115. \def\next##1{}\next}
  2116. % @quotation - narrow the margins.
  2117. \def\quotation{%
  2118. \begingroup\inENV %This group ends at the end of the @quotation body
  2119. {\parskip=0pt  % because we will skip by \parskip too, later
  2120. \aboveenvbreak}%
  2121. \singlespace
  2122. \parindent=0pt
  2123. \def\Equotation{\par\endgroup\afterenvbreak}%
  2124. % @cartouche defines \nonarrowing to inhibit narrowing
  2125. % at next level down.
  2126. \ifx\nonarrowing\relax
  2127. \advance \leftskip by \lispnarrowing
  2128. \advance \rightskip by \lispnarrowing
  2129. \exdentamount=\lispnarrowing
  2130. \let\nonarrowing=\relax
  2131. \message{defuns,}
  2132. % Define formatter for defuns
  2133. % First, allow user to change definition object font (\df) internally
  2134. \def\setdeffont #1 {\csname DEF#1\endcsname}
  2135. \newskip\defbodyindent \defbodyindent=.4in
  2136. \newskip\defargsindent \defargsindent=50pt
  2137. \newskip\deftypemargin \deftypemargin=12pt
  2138. \newskip\deflastargmargin \deflastargmargin=18pt
  2139. \newcount\parencount
  2140. % define \functionparens, which makes ( and ) and & do special things.
  2141. % \functionparens affects the group it is contained in.
  2142. \def\activeparens{%
  2143. \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
  2144. \catcode`\[=\active \catcode`\]=\active}
  2145. % Make control sequences which act like normal parenthesis chars.
  2146. \let\lparen = ( \let\rparen = )
  2147. {\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
  2148. % Be sure that we always have a definition for `(', etc.  For example,
  2149. % if the fn name has parens in it, \boldbrax will not be in effect yet,
  2150. % so TeX would otherwise complain about undefined control sequence.
  2151. \global\let(=\lparen \global\let)=\rparen
  2152. \global\let[=\lbrack \global\let]=\rbrack
  2153. \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
  2154. \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
  2155. % Definitions of (, ) and & used in args for functions.
  2156. % This is the definition of ( outside of all parentheses.
  2157. \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested %
  2158. \global\advance\parencount by 1 }
  2159. % This is the definition of ( when already inside a level of parens.
  2160. \gdef\opnested{\char`\(\global\advance\parencount by 1 }
  2161. \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
  2162. % also in that case restore the outer-level definition of (.
  2163. \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
  2164. \global\advance \parencount by -1 }
  2165. % If we encounter &foo, then turn on ()-hacking afterwards
  2166. \gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ }
  2167. \gdef\normalparens{\boldbrax\let&=\ampnr}
  2168. } % End of definition inside \activeparens
  2169. %% These parens (in \boldbrax) actually are a little bolder than the
  2170. %% contained text.  This is especially needed for [ and ]
  2171. \def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&}
  2172. \def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}}
  2173. % First, defname, which formats the header line itself.
  2174. % #1 should be the function name.
  2175. % #2 should be the type of definition, such as "Function".
  2176. \def\defname #1#2{%
  2177. % Get the values of \leftskip and \rightskip as they were
  2178. % outside the @def...
  2179. \dimen2=\leftskip
  2180. \advance\dimen2 by -\defbodyindent
  2181. \dimen3=\rightskip
  2182. \advance\dimen3 by -\defbodyindent
  2183. \noindent        %
  2184. \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
  2185. \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
  2186. \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
  2187. \parshape 2 0in \dimen0 \defargsindent \dimen1     %
  2188. % Now output arg 2 ("Function" or some such)
  2189. % ending at \deftypemargin from the right margin,
  2190. % but stuck inside a box of width 0 so it does not interfere with linebreaking
  2191. {% Adjust \hsize to exclude the ambient margins,
  2192. % so that \rightline will obey them.
  2193. \advance \hsize by -\dimen2 \advance \hsize by -\dimen3
  2194. \rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}%
  2195. % Make all lines underfull and no complaints:
  2196. \tolerance=10000 \hbadness=10000    
  2197. \advance\leftskip by -\defbodyindent
  2198. \exdentamount=\defbodyindent
  2199. {\df #1}\enskip        % Generate function name
  2200. % Actually process the body of a definition
  2201. % #1 should be the terminating control sequence, such as \Edefun.
  2202. % #2 should be the "another name" control sequence, such as \defunx.
  2203. % #3 should be the control sequence that actually processes the header,
  2204. %    such as \defunheader.
  2205. \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  2206. \medbreak %
  2207. % Define the end token that this defining construct specifies
  2208. % so that it will exit this group.
  2209. \def#1{\endgraf\endgroup\medbreak}%
  2210. \def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
  2211. \parindent=0in
  2212. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2213. \exdentamount=\defbodyindent
  2214. \begingroup %
  2215. \catcode 61=\active %
  2216. \obeylines\activeparens\spacesplit#3}
  2217. \def\defmethparsebody #1#2#3#4 {\begingroup\inENV %
  2218. \medbreak %
  2219. % Define the end token that this defining construct specifies
  2220. % so that it will exit this group.
  2221. \def#1{\endgraf\endgroup\medbreak}%
  2222. \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
  2223. \parindent=0in
  2224. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2225. \exdentamount=\defbodyindent
  2226. \begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
  2227. \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
  2228. \medbreak %
  2229. % Define the end token that this defining construct specifies
  2230. % so that it will exit this group.
  2231. \def#1{\endgraf\endgroup\medbreak}%
  2232. \def#2##1 ##2 {\def#4{##1}%
  2233. \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
  2234. \parindent=0in
  2235. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2236. \exdentamount=\defbodyindent
  2237. \begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
  2238. % These parsing functions are similar to the preceding ones
  2239. % except that they do not make parens into active characters.
  2240. % These are used for "variables" since they have no arguments.
  2241. \def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  2242. \medbreak %
  2243. % Define the end token that this defining construct specifies
  2244. % so that it will exit this group.
  2245. \def#1{\endgraf\endgroup\medbreak}%
  2246. \def#2{\begingroup\obeylines\spacesplit#3}%
  2247. \parindent=0in
  2248. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2249. \exdentamount=\defbodyindent
  2250. \begingroup %
  2251. \catcode 61=\active %
  2252. \obeylines\spacesplit#3}
  2253. \def\defvrparsebody #1#2#3#4 {\begingroup\inENV %
  2254. \medbreak %
  2255. % Define the end token that this defining construct specifies
  2256. % so that it will exit this group.
  2257. \def#1{\endgraf\endgroup\medbreak}%
  2258. \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
  2259. \parindent=0in
  2260. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2261. \exdentamount=\defbodyindent
  2262. \begingroup\obeylines\spacesplit{#3{#4}}}
  2263. \def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV %
  2264. \medbreak %
  2265. % Define the end token that this defining construct specifies
  2266. % so that it will exit this group.
  2267. \def#1{\endgraf\endgroup\medbreak}%
  2268. \def#2##1 ##2 {\def#4{##1}%
  2269. \begingroup\obeylines\spacesplit{#3{##2}}}%
  2270. \parindent=0in
  2271. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2272. \exdentamount=\defbodyindent
  2273. \begingroup\obeylines\spacesplit{#3{#5}}}
  2274. % Split up #2 at the first space token.
  2275. % call #1 with two arguments:
  2276. %  the first is all of #2 before the space token,
  2277. %  the second is all of #2 after that space token.
  2278. % If #2 contains no space token, all of it is passed as the first arg
  2279. % and the second is passed as empty.
  2280. {\obeylines
  2281. \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
  2282. \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
  2283. \ifx\relax #3%
  2284. #1{#2}{}\else #1{#2}{#3#4}\fi}}
  2285. % So much for the things common to all kinds of definitions.
  2286. % Define @defun.
  2287. % First, define the processing that is wanted for arguments of \defun
  2288. % Use this to expand the args and terminate the paragraph they make up
  2289. \def\defunargs #1{\functionparens \sl
  2290. % Expand, preventing hyphenation at `-' chars.
  2291. % Note that groups don't affect changes in \hyphenchar.
  2292. \hyphenchar\tensl=0
  2293. \hyphenchar\tensl=45
  2294. \ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi%
  2295. \interlinepenalty=10000
  2296. \advance\rightskip by 0pt plus 1fil
  2297. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  2298. \def\deftypefunargs #1{%
  2299. % Expand, preventing hyphenation at `-' chars.
  2300. % Note that groups don't affect changes in \hyphenchar.
  2301. \functionparens
  2302. \code{#1}%
  2303. \interlinepenalty=10000
  2304. \advance\rightskip by 0pt plus 1fil
  2305. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  2306. % Do complete processing of one @defun or @defunx line already parsed.
  2307. % @deffn Command forward-char nchars
  2308. \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
  2309. \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
  2310. \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
  2311. \catcode 61=\other % Turn off change made in \defparsebody
  2312. % @defun == @deffn Function
  2313. \def\defun{\defparsebody\Edefun\defunx\defunheader}
  2314. \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2315. \begingroup\defname {#1}{Function}%
  2316. \defunargs {#2}\endgroup %
  2317. \catcode 61=\other % Turn off change made in \defparsebody
  2318. % @deftypefun int foobar (int @var{foo}, float @var{bar})
  2319. \def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
  2320. % #1 is the data type.  #2 is the name and args.
  2321. \def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
  2322. % #1 is the data type, #2 the name, #3 the args.
  2323. \def\deftypefunheaderx #1#2 #3\relax{%
  2324. \doind {fn}{\code{#2}}% Make entry in function index
  2325. \begingroup\defname {\code{#1} #2}{Function}%
  2326. \deftypefunargs {#3}\endgroup %
  2327. \catcode 61=\other % Turn off change made in \defparsebody
  2328. % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
  2329. \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
  2330. % #1 is the classification.  #2 is the data type.  #3 is the name and args.
  2331. \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
  2332. % #1 is the classification, #2 the data type, #3 the name, #4 the args.
  2333. \def\deftypefnheaderx #1#2#3 #4\relax{%
  2334. \doind {fn}{\code{#3}}% Make entry in function index
  2335. \begingroup\defname {\code{#2} #3}{#1}%
  2336. \deftypefunargs {#4}\endgroup %
  2337. \catcode 61=\other % Turn off change made in \defparsebody
  2338. % @defmac == @deffn Macro
  2339. \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
  2340. \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2341. \begingroup\defname {#1}{Macro}%
  2342. \defunargs {#2}\endgroup %
  2343. \catcode 61=\other % Turn off change made in \defparsebody
  2344. % @defspec == @deffn Special Form
  2345. \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
  2346. \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2347. \begingroup\defname {#1}{Special Form}%
  2348. \defunargs {#2}\endgroup %
  2349. \catcode 61=\other % Turn off change made in \defparsebody
  2350. % This definition is run if you use @defunx
  2351. % anywhere other than immediately after a @defun or @defunx.
  2352. \def\deffnx #1 {\errmessage{@deffnx in invalid context}}
  2353. \def\defunx #1 {\errmessage{@defunx in invalid context}}
  2354. \def\defmacx #1 {\errmessage{@defmacx in invalid context}}
  2355. \def\defspecx #1 {\errmessage{@defspecx in invalid context}}
  2356. \def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}}
  2357. \def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}}
  2358. % @defmethod, and so on
  2359. % @defop {Funny Method} foo-class frobnicate argument
  2360. \def\defop #1 {\def\defoptype{#1}%
  2361. \defopparsebody\Edefop\defopx\defopheader\defoptype}
  2362. \def\defopheader #1#2#3{%
  2363. \dosubind {fn}{\code{#2}}{on #1}% Make entry in function index
  2364. \begingroup\defname {#2}{\defoptype{} on #1}%
  2365. \defunargs {#3}\endgroup %
  2366. % @defmethod == @defop Method
  2367. \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
  2368. \def\defmethodheader #1#2#3{%
  2369. \dosubind {fn}{\code{#2}}{on #1}% entry in function index
  2370. \begingroup\defname {#2}{Method on #1}%
  2371. \defunargs {#3}\endgroup %
  2372. % @defcv {Class Option} foo-class foo-flag
  2373. \def\defcv #1 {\def\defcvtype{#1}%
  2374. \defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
  2375. \def\defcvarheader #1#2#3{%
  2376. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2377. \begingroup\defname {#2}{\defcvtype{} of #1}%
  2378. \defvarargs {#3}\endgroup %
  2379. % @defivar == @defcv {Instance Variable}
  2380. \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
  2381. \def\defivarheader #1#2#3{%
  2382. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2383. \begingroup\defname {#2}{Instance Variable of #1}%
  2384. \defvarargs {#3}\endgroup %
  2385. % These definitions are run if you use @defmethodx, etc.,
  2386. % anywhere other than immediately after a @defmethod, etc.
  2387. \def\defopx #1 {\errmessage{@defopx in invalid context}}
  2388. \def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
  2389. \def\defcvx #1 {\errmessage{@defcvx in invalid context}}
  2390. \def\defivarx #1 {\errmessage{@defivarx in invalid context}}
  2391. % Now @defvar
  2392. % First, define the processing that is wanted for arguments of @defvar.
  2393. % This is actually simple: just print them in roman.
  2394. % This must expand the args and terminate the paragraph they make up
  2395. \def\defvarargs #1{\normalparens #1%
  2396. \interlinepenalty=10000
  2397. \endgraf\penalty 10000\vskip -\parskip\penalty 10000}
  2398. % @defvr Counter foo-count
  2399. \def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
  2400. \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
  2401. \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
  2402. % @defvar == @defvr Variable
  2403. \def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
  2404. \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2405. \begingroup\defname {#1}{Variable}%
  2406. \defvarargs {#2}\endgroup %
  2407. % @defopt == @defvr {User Option}
  2408. \def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
  2409. \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2410. \begingroup\defname {#1}{User Option}%
  2411. \defvarargs {#2}\endgroup %
  2412. % @deftypevar int foobar
  2413. \def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
  2414. % #1 is the data type.  #2 is the name.
  2415. \def\deftypevarheader #1#2{%
  2416. \doind {vr}{\code{#2}}% Make entry in variables index
  2417. \begingroup\defname {\code{#1} #2}{Variable}%
  2418. \interlinepenalty=10000
  2419. \endgraf\penalty 10000\vskip -\parskip\penalty 10000
  2420. \endgroup}
  2421. % @deftypevr {Global Flag} int enable
  2422. \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
  2423. \def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}%
  2424. \begingroup\defname {\code{#2} #3}{#1}
  2425. \interlinepenalty=10000
  2426. \endgraf\penalty 10000\vskip -\parskip\penalty 10000
  2427. \endgroup}
  2428. % This definition is run if you use @defvarx
  2429. % anywhere other than immediately after a @defvar or @defvarx.
  2430. \def\defvrx #1 {\errmessage{@defvrx in invalid context}}
  2431. \def\defvarx #1 {\errmessage{@defvarx in invalid context}}
  2432. \def\defoptx #1 {\errmessage{@defoptx in invalid context}}
  2433. \def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}}
  2434. \def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}}
  2435. % Now define @deftp
  2436. % Args are printed in bold, a slight difference from @defvar.
  2437. \def\deftpargs #1{\bf \defvarargs{#1}}
  2438. % @deftp Class window height width ...
  2439. \def\deftp{\defvrparsebody\Edeftp\deftpx\deftpheader}
  2440. \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
  2441. \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
  2442. % This definition is run if you use @deftpx, etc
  2443. % anywhere other than immediately after a @deftp, etc.
  2444. \def\deftpx #1 {\errmessage{@deftpx in invalid context}}
  2445. \message{cross reference,}
  2446. % Define cross-reference macros
  2447. \newwrite \auxfile
  2448. \newif\ifhavexrefs  % True if xref values are known.
  2449. \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
  2450. % \setref{foo} defines a cross-reference point named foo.
  2451. \def\setref#1{%
  2452. %\dosetq{#1-title}{Ytitle}%
  2453. \dosetq{#1-pg}{Ypagenumber}%
  2454. \dosetq{#1-snt}{Ysectionnumberandtype}}
  2455. \def\unnumbsetref#1{%
  2456. %\dosetq{#1-title}{Ytitle}%
  2457. \dosetq{#1-pg}{Ypagenumber}%
  2458. \dosetq{#1-snt}{Ynothing}}
  2459. \def\appendixsetref#1{%
  2460. %\dosetq{#1-title}{Ytitle}%
  2461. \dosetq{#1-pg}{Ypagenumber}%
  2462. \dosetq{#1-snt}{Yappendixletterandtype}}
  2463. % \xref, \pxref, and \ref generate cross-references to specified points.
  2464. % For \xrefX, #1 is the node name, #2 the name of the Info
  2465. % cross-reference, #3 the printed node name, #4 the name of the Info
  2466. % file, #5 the name of the printed manual.  All but the node name can be
  2467. % omitted.
  2468. \def\pxref#1{see \xrefX[#1,,,,,,,]}
  2469. \def\xref#1{See \xrefX[#1,,,,,,,]}
  2470. \def\ref#1{\xrefX[#1,,,,,,,]}
  2471. \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup%
  2472. \def\printedmanual{\ignorespaces #5}%
  2473. \def\printednodename{\ignorespaces #3}%
  2474. \setbox1=\hbox{\printedmanual}%
  2475. \setbox0=\hbox{\printednodename}%
  2476. \ifdim \wd0=0pt%
  2477. \def\printednodename{\ignorespaces #1}%
  2478. %%% Uncommment the following line to make the actual chapter or section title
  2479. %%% appear inside the square brackets.
  2480. %\def\printednodename{#1-title}%
  2481. % If we use \unhbox0 and \unhbox1 to print the node names, TeX does
  2482. % not insert empty discretionaries after hyphens, which means that it
  2483. % will not find a line break at a hyphen in a node names.  Since some
  2484. % manuals are best written with fairly long node names, containing
  2485. % hyphens, this is a loss.  Therefore, we simply give the text of
  2486. % the node name again, so it is as if TeX is seeing it for the first
  2487. % time.
  2488. \ifdim \wd1>0pt
  2489. section ``\printednodename'' in \cite{\printedmanual}%
  2490. \else%
  2491. \turnoffactive%
  2492. \refx{#1-snt}{} [\printednodename], page\tie\refx{#1-pg}{}%
  2493. \endgroup}
  2494. % \dosetq is the interface for calls from other macros
  2495. % Use \turnoffactive so that punctuation chars such as underscore
  2496. % work in node names.
  2497. \def\dosetq #1#2{{\let\folio=0 \turnoffactive%
  2498. \edef\next{\write\auxfile{\internalsetq {#1}{#2}}}%
  2499. \next}}
  2500. % \internalsetq {foo}{page} expands into
  2501. % CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
  2502. % When the aux file is read, ' is the escape character
  2503. \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
  2504. % Things to be expanded by \internalsetq
  2505. \def\Ypagenumber{\folio}
  2506. \def\Ytitle{\thischapter}
  2507. \def\Ynothing{}
  2508. \def\Ysectionnumberandtype{%
  2509. \ifnum\secno=0 Chapter\xreftie\the\chapno %
  2510. \else \ifnum \subsecno=0 Section\xreftie\the\chapno.\the\secno %
  2511. \else \ifnum \subsubsecno=0 %
  2512. Section\xreftie\the\chapno.\the\secno.\the\subsecno %
  2513. \else %
  2514. Section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
  2515. \fi \fi \fi }
  2516. \def\Yappendixletterandtype{%
  2517. \ifnum\secno=0 Appendix\xreftie'char\the\appendixno{}%
  2518. \else \ifnum \subsecno=0 Section\xreftie'char\the\appendixno.\the\secno %
  2519. \else \ifnum \subsubsecno=0 %
  2520. Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
  2521. \else %
  2522. Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
  2523. \fi \fi \fi }
  2524. \gdef\xreftie{'tie}
  2525. % Use TeX 3.0's \inputlineno to get the line number, for better error
  2526. % messages, but if we're using an old version of TeX, don't do anything.
  2527. \ifx\inputlineno\thisisundefined
  2528.   \let\linenumber = \empty % Non-3.0.
  2529. \else
  2530.   \def\linenumber{\the\inputlineno:\space}
  2531. % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
  2532. % If its value is nonempty, SUFFIX is output afterward.
  2533. \def\refx#1#2{%
  2534.   \expandafter\ifx\csname X#1\endcsname\relax
  2535.     % If not defined, say something at least.
  2536.     $\langle$un\-de\-fined$\rangle$%
  2537.     \ifhavexrefs
  2538.       \message{\linenumber Undefined cross reference `#1'.}%
  2539.     \else
  2540.       \ifwarnedxrefs\else
  2541.         \global\warnedxrefstrue
  2542.         \message{Cross reference values unknown; you must run TeX again.}%
  2543.       \fi
  2544.     \fi
  2545.   \else
  2546.     % It's defined, so just use it.
  2547.     \csname X#1\endcsname
  2548.   \fi
  2549.   #2% Output the suffix in any case.
  2550. % Read the last existing aux file, if any.  No error if none exists.
  2551. % This is the macro invoked by entries in the aux file.
  2552. \def\xrdef #1#2{
  2553. {\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}}
  2554. \def\readauxfile{%
  2555. \begingroup
  2556. \catcode `\^^@=\other
  2557. \catcode `\
  2558. =\other
  2559. \catcode `\
  2560. =\other
  2561. \catcode `\^^C=\other
  2562. \catcode `\^^D=\other
  2563. \catcode `\^^E=\other
  2564. \catcode `\^^F=\other
  2565. \catcode `\^^G=\other
  2566. \catcode `\^^H=\other
  2567. \catcode `\
  2568. =\other
  2569. \catcode `\^^L=\other
  2570. \catcode `\
  2571. =\other
  2572. \catcode `\
  2573. =\other
  2574. \catcode `\
  2575. =\other
  2576. \catcode `\
  2577. =\other
  2578. \catcode `\
  2579. =\other
  2580. \catcode `\
  2581. =\other
  2582. \catcode `\
  2583. =\other
  2584. \catcode `\
  2585. =\other
  2586. \catcode `\
  2587. =\other
  2588. \catcode `\
  2589. =\other
  2590. \catcode `\
  2591. =\other
  2592. \catcode `\
  2593. =\other
  2594. \catcode 26=\other
  2595. \catcode `\^^[=\other
  2596. \catcode `\^^\=\other
  2597. \catcode `\^^]=\other
  2598. \catcode `\^^^=\other
  2599. \catcode `\^^_=\other
  2600. \catcode `\@=\other
  2601. \catcode `\^=\other
  2602. \catcode `\~=\other
  2603. \catcode `\[=\other
  2604. \catcode `\]=\other
  2605. \catcode`\"=\other
  2606. \catcode`\_=\other
  2607. \catcode`\|=\other
  2608. \catcode`\<=\other
  2609. \catcode`\>=\other
  2610. \catcode `\$=\other
  2611. \catcode `\#=\other
  2612. \catcode `\&=\other
  2613. % `\+ does not work, so use 43.
  2614. \catcode 43=\other
  2615. % the aux file uses ' as the escape.
  2616. % Turn off \ as an escape so we do not lose on
  2617. % entries which were dumped with control sequences in their names.
  2618. % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
  2619. % Reference to such entries still does not work the way one would wish,
  2620. % but at least they do not bomb out when the aux file is read in.
  2621. \catcode `\{=1 \catcode `\}=2
  2622. \catcode `\%=\other
  2623. \catcode `\'=0
  2624. \catcode `\\=\other
  2625. \openin 1 \jobname.aux
  2626. \ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue
  2627. % Open the new aux file.  Tex will close it automatically at exit.
  2628. \openout \auxfile=\jobname.aux
  2629. \endgroup}
  2630. % Footnotes.
  2631. \newcount \footnoteno
  2632. % The trailing space in the following definition for supereject is
  2633. % vital for proper filling; pages come out unaligned when you do a
  2634. % pagealignmacro call if that space before the closing brace is
  2635. % removed.
  2636. \def\supereject{\par\penalty -20000\footnoteno =0 }
  2637. % @footnotestyle is meaningful for info output only..
  2638. \let\footnotestyle=\comment
  2639. \let\ptexfootnote=\footnote
  2640. {\catcode `\@=11
  2641. \long\gdef\footnote #1{\global\advance \footnoteno by \@ne
  2642. \unskip
  2643. \edef\thisfootno{$^{\the\footnoteno}$}%
  2644. \let\@sf\empty
  2645. \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
  2646. \thisfootno\@sf \footnotezzz{#1}}
  2647. % \parsearg\footnotezzz}
  2648. \long\gdef\footnotezzz #1{\insert\footins{
  2649. \interlinepenalty\interfootnotelinepenalty
  2650. \splittopskip\ht\strutbox % top baseline for broken footnotes
  2651. \splitmaxdepth\dp\strutbox \floatingpenalty\@MM
  2652. \leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip
  2653. \footstrut\parindent=\defaultparindent\hang\textindent{\thisfootno}#1\strut}}
  2654. }%end \catcode `\@=11
  2655. % End of control word definitions.
  2656. \message{and turning on texinfo input format.}
  2657. \def\openindices{%
  2658.    \newindex{cp}%
  2659.    \newcodeindex{fn}%
  2660.    \newcodeindex{vr}%
  2661.    \newcodeindex{tp}%
  2662.    \newcodeindex{ky}%
  2663.    \newcodeindex{pg}%
  2664. % Set some numeric style parameters, for 8.5 x 11 format.
  2665. %\hsize = 6.5in
  2666. \newdimen\defaultparindent \defaultparindent = 15pt
  2667. \parindent = \defaultparindent
  2668. \parskip 18pt plus 1pt
  2669. \baselineskip 15pt
  2670. \advance\topskip by 1.2cm
  2671. % Prevent underfull vbox error messages.
  2672. \vbadness=10000
  2673. % Following George Bush, just get rid of widows and orphans.
  2674. \widowpenalty=10000
  2675. \clubpenalty=10000
  2676. % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
  2677. % using an old version of TeX, don't do anything.  We want the amount of
  2678. % stretch added to depend on the line length, hence the dependence on
  2679. % \hsize.  This makes it come to about 9pt for the 8.5x11 format.
  2680. \ifx\emergencystretch\thisisundefined \else
  2681.   \emergencystretch = \hsize
  2682.   \divide\emergencystretch by 45
  2683. % Use @smallbook to reset parameters for 7x9.5 format  (or else 7x9.25)
  2684. \def\smallbook{
  2685. % These values for secheadingskip and subsecheadingskip are
  2686. % experiments.  RJC 7 Aug 1992
  2687. \global\secheadingskip = 17pt plus 6pt minus 3pt
  2688. \global\subsecheadingskip = 14pt plus 6pt minus 3pt
  2689. \global\lispnarrowing = 0.3in
  2690. \global\baselineskip 12pt
  2691. \advance\topskip by -1cm
  2692. \global\parskip 3pt plus 1pt
  2693. \global\hsize = 5in
  2694. \global\vsize=7.5in
  2695. \global\tolerance=700
  2696. \global\hfuzz=1pt
  2697. \global\contentsrightmargin=0pt
  2698. \global\pagewidth=\hsize
  2699. \global\pageheight=\vsize
  2700. \global\let\smalllisp=\smalllispx
  2701. \global\let\smallexample=\smalllispx
  2702. \global\def\Esmallexample{\Esmalllisp}
  2703. % Use @afourpaper to print on European A4 paper.
  2704. \def\afourpaper{
  2705. \global\tolerance=700
  2706. \global\hfuzz=1pt
  2707. \global\baselineskip=12pt
  2708. \global\parskip 15pt plus 1pt
  2709. \global\vsize= 53\baselineskip
  2710. \advance\vsize by \topskip
  2711. %\global\hsize=   5.85in     % A4 wide 10pt
  2712. \global\hsize=  6.5in
  2713. \global\outerhsize=\hsize
  2714. \global\advance\outerhsize by 0.5in
  2715. \global\outervsize=\vsize
  2716. \global\advance\outervsize by 0.6in
  2717. \global\pagewidth=\hsize
  2718. \global\pageheight=\vsize
  2719. %% For a final copy, take out the rectangles
  2720. %% that mark overfull boxes (in case you have decided
  2721. %% that the text looks ok even though it passes the margin).
  2722. \def\finalout{\overfullrule=0pt}
  2723. % Define macros to output various characters with catcode for normal text.
  2724. \catcode`\"=\other
  2725. \catcode`\~=\other
  2726. \catcode`\^=\other
  2727. \catcode`\_=\other
  2728. \catcode`\|=\other
  2729. \catcode`\<=\other
  2730. \catcode`\>=\other
  2731. \catcode`\+=\other
  2732. \def\normaldoublequote{"}
  2733. \def\normaltilde{~}
  2734. \def\normalcaret{^}
  2735. \def\normalunderscore{_}
  2736. \def\normalverticalbar{|}
  2737. \def\normalless{<}
  2738. \def\normalgreater{>}
  2739. \def\normalplus{+}
  2740. % This macro is used to make a character print one way in ttfont
  2741. % where it can probably just be output, and another way in other fonts,
  2742. % where something hairier probably needs to be done.
  2743. % #1 is what to print if we are indeed using \tt; #2 is what to print
  2744. % otherwise.  Since all the Computer Modern typewriter fonts have zero
  2745. % interword stretch (and shrink), and it is reasonable to expect all
  2746. % typewriter fonts to have this, we can check that font parameter.
  2747. \def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi}
  2748. % Turn off all special characters except @
  2749. % (and those which the user can use as if they were ordinary).
  2750. % Most of these we simply print from the \tt font, but for some, we can
  2751. % use math or other variants that look better in normal text.
  2752. \catcode`\"=\active
  2753. \def\activedoublequote{{\tt \char '042}}
  2754. \let"=\activedoublequote
  2755. \catcode`\~=\active
  2756. \def~{{\tt \char '176}}
  2757. \chardef\hat=`\^
  2758. \catcode`\^=\active
  2759. \def^{{\tt \hat}}
  2760. \catcode`\_=\active
  2761. \def_{\ifusingtt\normalunderscore\_}
  2762. % Subroutine for the previous macro.
  2763. \def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}}
  2764. % \lvvmode is equivalent in function to \leavevmode.
  2765. % Using \leavevmode runs into trouble when written out to
  2766. % an index file due to the expansion of \leavevmode into ``\unhbox
  2767. % \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our
  2768. % magic tricks with @.
  2769. \def\lvvmode{\vbox to 0pt{}}
  2770. \catcode`\|=\active
  2771. \def|{{\tt \char '174}}
  2772. \chardef \less=`\<
  2773. \catcode`\<=\active
  2774. \def<{{\tt \less}}
  2775. \chardef \gtr=`\>
  2776. \catcode`\>=\active
  2777. \def>{{\tt \gtr}}
  2778. \catcode`\+=\active
  2779. \def+{{\tt \char 43}}
  2780. %\catcode 27=\active
  2781. %\def^^[{$\diamondsuit$}
  2782. % Used sometimes to turn off (effectively) the active characters
  2783. % even after parsing them.
  2784. \def\turnoffactive{\let"=\normaldoublequote
  2785. \let~=\normaltilde
  2786. \let^=\normalcaret
  2787. \let_=\normalunderscore
  2788. \let|=\normalverticalbar
  2789. \let<=\normalless
  2790. \let>=\normalgreater
  2791. \let+=\normalplus}
  2792. % Set up an active definition for =, but don't enable it most of the time.
  2793. {\catcode`\==\active
  2794. \global\def={{\tt \char 61}}}
  2795. \catcode`\@=0
  2796. % \rawbackslashxx output one backslash character in current font
  2797. \global\chardef\rawbackslashxx=`\\
  2798. %{\catcode`\\=\other
  2799. %@gdef@rawbackslashxx{\}}
  2800. % \rawbackslash redefines \ as input to do \rawbackslashxx.
  2801. {\catcode`\\=\active
  2802. @gdef@rawbackslash{@let\=@rawbackslashxx }}
  2803. % \normalbackslash outputs one backslash in fixed width font.
  2804. \def\normalbackslash{{\tt\rawbackslashxx}}
  2805. % Say @foo, not \foo, in error messages.
  2806. \escapechar=`\@
  2807. % \catcode 17=0   % Define control-q
  2808. \catcode`\\=\active
  2809. % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
  2810. % That is what \eatinput is for; after that, the `\' should revert to printing 
  2811. % a backslash.
  2812. @gdef@eatinput input texinfo{@fixbackslash}
  2813. @global@let\ = @eatinput
  2814. % On the other hand, perhaps the file did not have a `\input texinfo'. Then
  2815. % the first `\{ in the file would cause an error. This macro tries to fix 
  2816. % that, assuming it is called before the first `\' could plausibly occur.
  2817. @gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi}
  2818. %% These look ok in all fonts, so just make them not special.  The @rm below
  2819. %% makes sure that the current font starts out as the newly loaded cmr10
  2820. @catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other
  2821. @textfonts
  2822. @c Local variables:
  2823. @c page-delimiter: "^\\\\message"
  2824. @c End:
  2825.